MALAR PUBLIC SENIOR SECONDARY SCHOOL
(Affiliated - CBSE, New Delhi, Affiliation No:(1931085)
Paramathi, P.Velur (Tk.), Namakkal (Dt.)- 637 207
CLASS XI CS WORKSHEET- FLOW OF CONTROL
1. What does the following Python program display ?
x=3
if x == 0:
print ("Am I here?", end = ' ')
elif x == 3:
print("Or here?", end = ' ')
else :
pass
print ("Or over here?")
2. What values are generated when the function range(6, 0, -2) is executed ? 3.
Consider the loop given below :
for i in range(-5) :
print(i)
4. When the following code runs, how many times is the line "x = x * 2"
executed?
x=1
while ( x < 20 ):
x=x*2
5. What is the output produced when this code executes?
i=1
while (i <= 7):
i*= 2
print (i)
6. What is the output produced when this code executes?
a=0
for i in range(4,8):
if i % 2 == 0:
a=a+i
print (a)
7. Write a program to generate the sequence: –5, 10,–15, 20, –25..... upto n,
where n is an integer input by the user.
8. Find the output of the following program segments:
i) a = 110
while a > 100:
print(a)
a -= 2
(ii) for x in range(1,4):
for y in range(2,5):
if x * y > 10:
break
print (x * y)
9. Write a program to get name and age from the user and find whether that
person is eligible to cast vote or not..
10. Write a program to find the sum of digits of an integer, input given by user.
MALAR PUBLIC SENIOR SECONDARY SCHOOL
(Affiliated - CBSE, New Delhi, Affiliation No:(1931085)
Paramathi, P.Velur (Tk.), Namakkal (Dt.)- 637 207
CLASS XI CS WORKSHEET- FLOW OF CONTROL
1. What does the following Python program display ?
x=3
if x == 0:
print ("Am I here?", end = ' ')
elif x == 3:
print("Or here?", end = ' ')
else :
pass
print ("Or over here?")
2. What values are generated when the function range(6, 0, -2) is executed ? 3.
Consider the loop given below :
for i in range(-5) :
print(i)
4. When the following code runs, how many times is the line "x = x * 2"
executed?
x=1
while ( x < 20 ):
x=x*2
5. What is the output produced when this code executes?
i=1
while (i <= 7):
i*= 2
print (i)
6. What is the output produced when this code executes?
a=0
for i in range(4,8):
if i % 2 == 0:
a=a+i
print (a)
7. Write a program to generate the sequence: –5, 10,–15, 20, –25..... upto n,
where n is an integer input by the user.
8. Find the output of the following program segments:
i) a = 110
while a > 100:
print(a)
a -= 2
(ii) for x in range(1,4):
for y in range(2,5):
if x * y > 10:
break
print (x * y)
9. Write a program to get name and age from the user and find whether that
person is eligible to cast vote or not..
10. Write a program to find the sum of digits of an integer, input given by user.