Codied To Clipboard !
Home > Notes > python
in this example u , will see the giving one value in the range
for i in range(10): print(i)
in this example u , will see the giving two parameter in the range. where the first parameter will be treated as starting limit and second parameter is treated as ending limit
for i in range(10,20): print(i)
in this example u , will see the giving Three parameter in the range. where the first parameter will be treated as starting limit and second parameter is treated as ending limit and last parameter is treated as interval.
for i in range(10,20,2): print(i)
in the below example u will see the example for loop with decending order in python.
for i in range(40,20,-2): print(i)
A nested loop is a loop inside a loop. The “inner loop” will be executed one time for each iteration of the “outer loop”:
for i in range(1,5): for j in range(7,10): print("i value is " , i) print("j value is " , j) print("\n") print("\n")
With the while loop we can execute a set of statements as long as a condition is true.
i = 1 while i < 6: print(i) i+=1