
Practice Questions of Loops in Python — Test 1
Q1. Write the output of the following: 1. for i in "Myblog": print (i, '?') 2. for i in range(5): print(i) 3. for i in range(10,15): print(i) Q2. Write a program to print first 10 natural number. Q3. Write a program to print first 10 even numbers. Q4. Write a program to print first 10 odd numbers. Q5. Write a program to print first 10 even numbers in reverse order. Q6. Write a program to print table of a number accepted from user. Q7. Write a program to display product of the digits of a number accepted from the user. Q8. Write a program to find the factorial of a number. Q9. Write a program to find the sum of the digits of a number accepted from user Q10. Write a program to check whether a number is prime or not.
Practice Questions of Loops in Python — Test 2
Q1. Write the output of the following
1. for i in (1,10):
print(i)
2. for i in (5,9):
print(i)
3. for i in range(2,7):
print(i)
4. for i in "csiplearninghub":
print(i)
5. for i in "python":
print(i, end=' ')
6. for i in "python":
print(i, end=='?')
7. for i in "python":
print(i, '?$')
8. for i in (1,2,3,4):
print(i)
9. for i in (3,4,7):
print(i)
10. for i in range(2,10,2):
print(i)
Practice Questions of Loops in Python — Test 3
Q1. Write the output of the following code :
x=5
while(x<15):
print(x**2)
x+=3
Â
a=7
b=5
while(a<9):
print(a+b)
a+=1
b=5
while(b<9):
print("H")
b+=1
b=15
while(b>9):
print("Hello")
b=b-2
Â
x=15
while(x==15):
print("Hello")
x=x-3
Â
x = "123"
for i in x:
print("a")
Â
i=9
while True:
if i%3==0:
break
print("A")
Â
a=6
while(a<=10):
print("a")
a+=1
Â
i=0
while i<3:
print(i)
i=i+1
else:
print(7)
Â
i=0
while i<3:
print(i)
i=i+1
print(0)
Â
i=2
for x in range(i):
i+=1
print(i)
print(i)
i=2
for x in range(i):
x+=1
print(x)
print(x)
Â
i=2
for x in range(i):
x+=1
print(x)
print("x")
Â
i=100
while i<57:
print(i)
i+=5
Practice Questions of Loops in Python — Test 4
Q1. Write program to print the following pattern.
a)
1
1 2
1 2 3
1 2 3 4
b)
* * * *
* * *
* *
*
Q2. Accept 10 numbers from the user and display their average.
Q3. Write a program to print all prime numbers  that fall between two numbers including both(accept two numbers from the user)
Q4. Write a program to display sum of odd numbers and even numbers that fall between 12 and 37(including both numbers)
Q5. Write a program to display all the numbers which are divisible by 11 but not by 2 between 100 and 500.
Q6. How many times the following loop execute?
c = 0
while c < 20:
     c += 2
Q7. Write the output of the following.
c = -9
while c < 20:
c += 3
 print(c)
Q8. Write a program to print numbers from 1 to 20 except multiple of 2 & 3.
Â
Q9. Write a program to print table of a number(accepted from user) in the following format.Â
    Like : input number is 7, so expected output is
    7 * 1 = 7
    7 * 2 = 14 and so on
Q10. Write a program that keep on accepting number from the user until user enters Zero. Display the sum and average of all the numbers.
Practice Questions of Loops in Python — Test 5
Q1. Write a program to print the following pattern
5 5 5 5 5
4 4 4 4
3 3 3
2 2
1
Q2. Find errors in the following code:
a = int(“Enter any number”)
for i in Range[2,6]
   if a=i
     print(“A”)
   else
     print(“B”)
Q3. Write a program to accept decimal number and display its binary number.
Q4. Accept a number and check whether it is palindrome or not.
Q5. Write a program to accept a number and check whether it is a perfect number or not.
(Perfect number is a positive integer which is equal to the sum of its divisors like divisors of 6 are 1,2,3, and
sum of divisors is also 6, so 6 is the perfect number)
Q6. Write a program to find the sum of the following series(accept values of x and n from user)
1 + x/1! + x2/2! + ……….xn/n!
Q7. Write a program to print the following pattern
A
B C
D E F
G H I J
K L M N O
Â
Q8. Write a program to find the sum of following (Accept values of a, r, n from user)
a + ar + ar2 + ar3 + ………..arn
Q9. Write the output of the following
for x in range(10,20): Â
if (x%2==0):
   continue
   print(x)
Q10. Write a function to display prime numbers below any number accepted from the user.
Practice Questions of Loops in Python — Test 6
Q1. Write the output of the following.
a=5
while a>0:
  print(a)
  a=a-1
Q2. for loop statement is terminated by symbol ___________
Q3. What is the difference between break and continue statements?
Â
Q4. Convert the following loop into for loop :
x = 4
while(x<=8):
  print(x*10)
  x+=2
Â
Q5. Write the output of the following:
for k in range(10,20,4):
  print(k)
Q6. Find errors in the following code:
x = input(“Enter value”)
for k in range[0,20]
  if x=k
    print(x+k)
  else:
    Print(x-k)
Q7. Write the output of the following:
x=3
if x>2 or x<5 and x==6:
  print(“Bye”)
else:
  print(“Thankyou”)
Q8. Write the output of the following:
x,y=2,4
if(x+y==10):
  print(“Thankyou”)
else:
  print(“Bye”)
Q9. Write the output of the following:
x=10
y=1
while x>y:
  x=x-4
  y=y+3
  print(x)
Q10. Write the output of the following:
for x in range(3):
  for y in range(2):
    print(“Practice Questions of loops in python”)
  print()
Â
Practice Questions of Loops in Python — Test 7
Q1. What do you mean by jump statement?
Q2. What is nested loop?
Q3. Write a program to print the following pattern.
1Â Â 2Â Â Â 3Â Â 4Â
1Â Â 2Â Â Â 3
1Â Â 2
1
Q4. Write a program to print the following pattern.
A
BÂ Â C
DÂ Â EÂ Â F
GÂ Â HÂ Â IÂ Â J
Q5. Write a program to print the following pattern.
AÂ Â AÂ Â AÂ Â A
AÂ Â AÂ Â AÂ Â A
AÂ Â AÂ Â AÂ Â A
AÂ Â AÂ Â AÂ Â A
Q6. Write a program to convert temperature in Fahrenheit to Celsius.
Q7. Write a program to print the factorial of a number.
Q8. Write a program to find the sum of digits of a number.
Q9. Accept two numbers from the user and display sum of even numbers between them(including both)
Q10. Write a program to reverse a number.
Â
Class 12 Computer Science Sample Paper 2020-2021.
Class 12 Computer Science Sample Paper Marking Scheme
Class 12 Computer Science Test Series


