Question
Write the difference between while loop and for loop

Answer

for Loopwhile Loop
It is used when we know the exact number of iterations.It is used when we know the exact number of iterations.
e.g.
for I in range(1,7):
print(i)
e.g.
while(1):
print("hello")

Need a full question paper?

Generate a complete, print-ready paper with questions like this in minutes — across 16+ boards, with answer keys.

Start Generating Free

Similar questions

What do you mean by authorisation and authentication?
Write the full form of DDL and DML?
Expand the following: GPRS, CDMA      
Rewrite the following code in python after removing all syntax error(s). Underline each correction done in the code.

What is VoIP?         
An application (program) is to be developed which offers choices to the user to calculate total surface area and volume of a cylinder, sphere, or cone. The application should input the user's choice and perform the corresponding operation.
Write a function to read the content from the file and display each word in reverse order.
Write two advantages of using an optical fiber cable over an Ethernet cable to connect two service stations, which are 190m away from each other.
Write SQL commands for the following:

Table: TEACHER

TID NAME AGE DEPT DATEOFJOIN SAL SEX
T118 Navin 40 Computer 2010-01-10 12000 M
T107 Chetna 37 History 2008-03-24 20000 F
T105 Sandeep 46 Maths 2006-12-12 30000 M
T110 Sangeeta 35 History 2010-07-01 25000 F
T101 Rudransh 42 Maths 2004-09-05 40000 M
T121 Neeraj 38 Physics 2011-04-01 28000 M

(i) To show information about the teachers of the history department.
(ii) To list the names of teachers earning a salary between 20000 and 30000.
(iii) To count the number of male teachers.
(iv) Display gender wise total number of teachers.
(v) To list the name and age of teachers of female teachers in descending order of date of join.
(vi) Increase the salary by 10% for Maths departments.
( vii) To delete the record of teacher Neeraj.

 Rewrite the above script, but this time to swap the values of variables without using the third variable.