Page 50 - 2501_KVS_C-8
P. 50
4.2 PRACTICE PROBLEMS ON ‘FOR’ LOOP
In this section, we will discuss and do some problems on ‘for’ loop for more clarity and
understanding of it. Students should practice the same in python.
Q1. Write a program in python to display the following series in separate lines using
‘for’ loop:
4 5 6 7 8 9 10 11 12
Ans. for i in range(4,13):
print(i)
Q2. Write a program in python to display the following series in separate lines using
‘for’ loop:
1 4 7 10 13 16 19
Ans. for i in range(1,20,3):
print(i)
Q3. Write a program in python to accept any two numbers from the user and display
the numbers that exist between them excluding them. E.g. if a user enters A=5 and
B=11, then the output should be 6, 7, 8, 9, 10.
A=int(input("Enter first number:"))
B=int(input("Enter second number:"))
for i in range(A+1,B):
print(i)
Q4. Write a program in python to accept a number from the user and display the
squares of natural numbers up to it. E.g. if the user enters N=5, then output should
be: 1 4 9 16 25
Ans. N=int(input("Enter a number:"))
for i in range(1,N+1):
print(i*i)
Q5. Write a program in python to accept a number from the user and display its
complete table. E.g. if the user enters N=5, then output should be:
5 10 15 20 25 30 35 40 45 50
Ans. N=int(input("Enter a number:"))
for i in range(1,11):
print(N*i)
Q6. Write a program in python to accept a number from the user and display the
following output. E.g. if the user enters N=5, then output should be:
---->> ---->> ---->> ---->> ---->>
Ans. N=int(input("Enter a number:"))
for i in range(1,N+1):
print("---->> ", end="")
48 KVS DELHI REGION 2025

