Exp4
Exp4
Experiement No : 4 Remark
Python For Loops :- A for loop is used for iterating over a sequence (that is either a list, a tuple, a
dictionary, a set, or a string). This is less like the for keyword in other programming languages, and works
more like an iterator method as found in other object-orientated programming languages.
With the for loop we can execute a set of statements, once for each item in a list, tuple, set etc.
for i in range ( start , stop , step )
Nested Loops :- A nested loop is a loop inside a loop. The "inner loop" will be executed one time for each
iteration of the "outer loop":
The while Loop :- With the while loop we can execute a set of statements as long as a condition is true.
Program (Write a number 1 to 5 ) Output
i=1 1
while i < 6: 2
print(i) 3
i += 1 4
5