For Loop in Python.
For loop is used for repeating the statements with in it. For loop is useful to iterate over the elements of sequence such as(a string, a list, a tuple, a dictionary, a set, or a range).
Syntax of For loop.
for variable in sequence: Body of for
Example of For loop with range() function in
for i in range(5):
print(i)
Output
0
1
2
3
4
1. Print the following output : **********
for i in range(1,11): print("*",end="")
2. Print the following output :
*
*
*
*
*
*
*
for i in range(1,11): print("*")
3. Print the following output :
*
COMPUHELP
*
COMPUHELP
*
COMPUHELP
*
COMPUHELP
*
COMPUHELP
*
COMPUHELP
*
for i in range(1,7): print(" *") print("COMPUHELP")
4. Print the series 0 to 9 using loops.
for i in range(0,10): print(i,end=" ")