100+ Important MCQ on Flow of Control in Python

Share with others

Flow of Control in Python

Flow of Control in python
Flow of Control in python

Q1. Python executes one statement after another from beginning to the end of the program. This is a ________________

a. Selection Construct

b. Sequential Construct

c. Iteration Construct

d. None of the above

Q2. The order of execution of the statements in a program is known as ______

a. flow of control

b. central flow

c. selection

d. iteration

Q3. Python supports _____________ types of control structures.

a. 1

b. 2

c. 3

d. 4

Q4. Which of the following are control structure in python?

a. Selection

b. Iteration

c. Both of the above

d. Sequential

Q5. In programming, the concept of decision making or selection is implemented with the help of ___________ statement

a. while loop

b. for loop

c. if..else

d. None of the above

Q6. Execution of statements in _________________ construct depend on a condition test.

a. Selection

b. Sequence

c. Iteration

d. Repetition

Q7. Correct syntax of writing ‘simple if’ statement is _____

a. 

if condition
statements
b. 

if (condition)
   statements
c. 

if condition :
   statements
d. 

if condition --
   statements

Q8. ______ statements can be written in if block.

a. 2

b. 4

c. 10

d. Any number of

Q9. Which of the following is variant of conditional statement in Python?

a. simple if without else

b. if .. else

c. if .. elif

d. All of the above

Q10. Number of elif in a program is dependent on the ___________

a. number of conditions to be checked

b. number of variables in a program

c. number of loops in a program

d. None of the above

Flow of Control in Python

Flow of Control in python
Flow of Control in python

Click here to check your performance in Flow of Control in Python MCQ

Flow of Control in Python

Q11. An ‘if’ condition inside another ‘if’ is called ___

a. Second if

b. nested if

c. another if

d. None of the above

Q12. Leading whitespace (spaces and tabs) at the beginning of a statement is called _________________.

a. indentation

b. orientation

c. Iteration

d. None of the above

Q13. Write the output of the following code :

if True:
 print("Hello")
else:
 print("Bye")

a. Bye

b. Hello

c. 

Bye 
Hello
d. 

Hello
Bye

Q14. Write the output of the following code :

y=2
if 2!=y:
 print("H")
else :
 print("K")

a. H

b. K

c. Error

d. Nothing will be printed

Q15. ____ is an empty statement in Python.

a. Jump

b. Fail

c. Empty

d. Pass

Q16. Which of the following statement is not assigning a numerical value 8 to variable X, if original value of X is 0? ?

a. X = 8

b. X + = 8

c. X *= 8

d. None of the above

Q17. Write the output of the following :

x = 10
if x > 7:
 print("Hello")
print("Bye")

a. Bye

b. Hello

c. 

Bye 
Hello
d. 

Hello
Bye

Q18. A statement inside ‘if’ has an indentation of _________ spaces.

a. 2

b. 4

c. 6

d. 8

Q19. Ravi wants to display “Hello”, if the condition is True, otherwise, “Pass” if the condition is False. Which of the following help to implement the same?

a. if statement

b. if .. else statement

c. if .. elif statement

d. for loop

Q20. Ram wants to create a program to check whether an year is leap year or not. For this he should have a good understanding of ____________

a. Conditional Statement

b. for loop

c. while loop

d. All of the above

Flow of Control in Python

Flow of Control in python
Flow of Control in python

Click here to check your performance in Flow of Control in Python MCQ

Flow of Control in Python

Q21. if-elif statement is used in situation which involves ____________

a. multiple condition

b. exactly one condition

c. Both of the above

d. None of the above

Q22. What is the purpose of ‘else’ statement in if-elif ladder?

a. else statement in if-elif will execute, if none of the condition is True.

b. else statement in if-elif will execute, if all the condition is True.

c. else statement in if-elif will execute, if the condition just above else statement is True

d. None of the above

Q23. To write else statement in if-elif ladder is mandatory? (T/F)

a. True

b. False

Q24. Number of elif in if-elif ladder depends on ____

a. number of conditions to be checked in program.

b. number of variables in program.

c. Both of the above

d. None of the above

Q25. A graphical representation that shows step by step solution to solve a given problem is ____________

a. Algorithm

b. Flow Chart

c. Line Chart

d. Pie Chart

Q26. Which of the following is not a keyword in Python?

a. True

b. False

c. if

d. For

Q27. Which of the following is not a conditional statement in Python?

a. if statement

b. if – else statement

c. if – elif statement

d. None of the above

Q28. Which of the following symbol is used to end an ‘if’ statement in Python?

a. Comma( , )

b. Colon( : )

c. Semi Colon( ; )

d. None of the above

Q29. Write the output of the following :

x = 10
if x > 7 and x <= 10:
 print("Pass", end="")
 print("Fail")

a. Pass

b. Fail

c. 

Pass
Fail

d. PassFail

Q30. Which of the following value of ‘x’ makes the condition False in the given code?

if (x > 7 or x == 3) and x!=11 :
 print("H")

a. 8

b. 9

c. 5

d. 33

Flow of Control in Python

Flow of Control in python
Flow of Control in python

Click here to check your performance in Flow of Control in Python MCQ

Flow of Control in Python

Q31. Write the output of the following :

if 'i' == "i" :
 print(True)
else:
 print("False")

a. True

b. False

c. Error

d. None of the above

Q32. Write the output of the following:

if (3+8//2 != 7):
 print("H")
else:
 print("B")

a. H

b. B

c. Error

d. None of the above

Q33. Write the output of the following:

a=5
b=6
c=7
d=8
if a > b:
    if c > a:
        if d < c:
             print("Hello")
        else:
             print("B")
    else:
           print("A")
print("What")

a. What

b. Hello

c. B

d. A

Q34. Write the output of the following:

a=15
b=6
c=7
d=8
if a > b:
    if c > a:
        if d < c:
             print("Hello")
        else:
             print("B")
    else:
           print("A")

a. Error

b. Hello

c. B

d. A

Q35. Write the output of the following:

a=155
b=126
c=237
d=388
if a > b:
    if c > a:
        if d < c:
             print("Hello")
        else:
             print("B")
    else:
           print("A")

a. Error

b. Hello

c. B

d. A

Q36. Repetition of a set of statements in a program is made possible using _____________

a. Selection Constructs

b. Sequential Constructs

c. Looping Constructs

d. None of the above

Q37. The statements in a loop are executed repeatedly as long as particular condition _____________.

a. remains False

b. remains True

c. gives error

d. None of the above

Q38. Condition in loops is checked based on the value of a variable called the ___________

a. loop’s special variable

b. loop’s control variable

c. loop’s execution variable

d. None of the above

Q39. When the condition in loops becomes false, the loop _________

a. terminates

b. begin

c. restart

d. none of the above

Q40. If the condition given in the loop never return False then the loop __________

a. never ends

b. ends after 50 times execution

c. ends after 150 times execution

d. give error

Flow of Control in Python


Click here to check your performance in Flow of Control in Python MCQ

Flow of Control in Python

Q41. Write the output of the following code :

for i in range(5):
 print(i)
a. 

0
1
2
3
4 
b. 

1
2
3
4
5
c. 

1
2
3
4
d. 

Error

Q42. Write the output of the following code :

for i in (1,2,3):
   print(i)
a. 


1
2
3
b. 

1
2
c. 


0
1
2
d. 

Error

Q43. Write the output of the following code :

for i in (2,3,4):
   print("i")
a. 

2
3
4
b. 

2
3
c. 

i
i
i
d. 

Error

Q44. Write the output of the following code :

for i in (4,3,2,1,0):
   print(i, end=" ")

a. 4 3 2 1 0

b. 4 3 2 1

c. 4

d. Error

Q45. Write the output of the following code :

for i in range(10):
    if(i%2!=0):
        print("Hello",i)
a. 

Hello 1
Hello 3
Hello 5
Hello 7
Hello 9
b. 

Hello 1
Hello 2
Hello 3
Hello 4
Hello 5
Hello 6
Hello 7
Hello 8
Hello 9
c. 

Hello 2
Hello 4
Hello 6
Hello 8
d. Error

Q46. Write the output of the following code :

for i in range(10,2,-2):
      print(i, "Hello")
a. 

10 Hello
8 Hello
6 Hello
4 Hello
b. 

10 
8 
6 
4 
Hello
Hello
Hello
Hello
c. 

10 Hello
8 Hello
6 Hello
4 Hello
2 Hello
d. 

Error

Q47. Write the output of the following code :

str = "Python Output based Questions"
word=str.split()
for i in word:
     print(i)
a. 

Python
Output
based
Questions
b. 

Python Output based Questions
c. 

PythonOutputbasedQuestions
d. 

Error

Q48. Write the output of the following code :

for i in range(7,10):
       print("Flow of control in Python")
print("Flow of control in Python")
a. 

Flow of control in Python
Flow of control in Python
Flow of control in Python
Flow of control in Python
b. 

Flow of control in Python
Flow of control in Python
c. 

Flow of control in Python
d. 

Error

Q49. Write the output of the following code :

for i in range(7,-2,-9):
      for j in range(i):
            print(j)
a. 


0
1
2
3
4
5
6
b. 

1
2
3
4
5
6
c. 

0
1
2
3
4
5
d. 

0
1
2
3

Q50. Write the output of the following code :

i="9"
for k in i:
      print(k)

a. 4

b. 9

c. 8

d. 5

Flow of Control in Python


Click here to check your performance in Flow of Control in Python MCQ

Flow of Control in Python

Q51. Write the output of the following code :

for i in range(1, 8):
      print(i)
      i+=2
a. 

1
2
3
4
5
6
7
b. 

0
1
2
3
4
5
6
c. 

1
2
3
4
5
6
d. 

Error

Q52. Write the output of the following code :

for i in range(4, 7):
      i=i+3
     print("Hello")
a. 

Hello
Hello
Hello
b. 

Hello
Hello
c. 

Hello
d. 

Error

Q53. Write the output of the following code :

for i in range(4,7):
      i=i+3
      print("Hello", i)
a. 

Hello 7
Hello 8
Hello 9
b. 

Hello 4
Hello 5
Hello 6
c. 

Hello 4
d. 

Error

Q54. Write the output of the following code :

i=4
while(i<10):
    i=i+3
    print(i)
a. 

7
10
b. 

4
5
6
7
8
9

c. 7

d. Error

Q55. Write the output of the following code :

for i in range(20):
    if i//4==0:
        print(i)
a. 

0
1
2
3
b. 

0
5
10
15
c. 

5
10
15

d. Error

Q56. Write the output of the following code :

x=1234
while x%10:
    x=x//10
    print(x)
a. 

123
12
1
b. 

123
12
1
0
c. 

123
12

d. Error

Q57. Write the output of the following code :

for i in 1,2,3:
    print(i*i)
a. 

1
4
9
b. 

1
2
3
c. 

1
2
3
4

d. Error

Q58. Write the output of the following code :

for i in 2,4,6:
    print("H"*i)
a. 

HH
HHH
HHHHH
b. 

HH
HHHH
HHHHHH
c. 

H
HH
HHHH
HHHHHH

d. Error

Q59. Write the output of the following code :

p=10
q=20
p=p*q//4
q=p+q**3
print(p,q)

a. 50 8050

b. 

50
8050
c. 

50
80
50

d. Error

Q60. Write the output of the following code :

x=2
y=6
x=x+y/2 + y//4
print(x)

a. 6

b. 6.0

c. 5

d. 5.0

Flow of Control in Python


Click here to check your performance in Flow of Control in Python MCQ

Flow of Control in Python

Q61. Write the output of the following :


a = 7
for i in 7:
    print(a)

a. Error

b. 

1
2
3
4
5
6

c. 7

d. No output

Q62. Write the output of the following code :


a = "AMIT"
for i in range(len(a)):
      print(a)

a. Error

b. 

AMIT
AMIT
AMIT
c. 

AMIT
AMIT
AMIT
AMIT
d. 

A
M
I
T

Q63. Write the output of the following code :


x = "Welcome to my blog"
j = "i"
while j in x:
     print(j)

a. No Output

b. Print “i” infinite times

c. Error

d. print ‘i’ five times

Q64. Write the output of the following code :

print(range (5, 0, -2))

a. range (5, 0, -2)

b. Error

c. No Output

d. 5 3 1

Q65. Write the output of the following code :


for i in range(0,2,-1):
     print("Hello")
a. 

Hello
Hello
Hello
b. 

Hello
Hello

c. No Output

d. Error

Q66. Write the output of the following code :

s1="csiplearninghub.com"
s2=""
s3=""
for x in s1:
    if(x=="s" or x=="n" or x=="p"):
        s2+=x
print(s2,end=" ")
print(s3)

a. spnn

b. nspp

c. npss

d. npps

Q67. Write the output of the following code :


s1="csiplearninghub.com"
c=0
for x in s1:
     if(x!="l"):
          c=c+1
print(c)

a. 16

b. 19

c. 17

d. 18

Q68. Write the output of the following code :


j=12
c=9
while(j):
     if(j>5):
          c=c+j-2
          j=j-1
     else:
          break
print(j, c)

a. 6 58

b. 5 58

c. Error

d. 5 60

Q69. Write the output of the following code :


L = [13 , 12 , 21 , 16 , 35 , 7, 4]
sum = 5
sum1 = 3
for i in L:
     if (i % 4 == 0):
           sum = sum + i
           continue
     if (i % 7 == 0):
          sum1 = sum1 + i
print(sum , end=" ")
print(sum1)

a. 37 66

b. 32 66

c. 35 66

d. 38 66

Q70. Write the output of the following code :

print('cs' + 'ip' if '234'.isdigit( ) else 'IT' + '-402')

a. IT-402

b. cs

c. csip

d. Error

Flow of Control in Python


Click here to check your performance in Flow of Control in Python MCQ

Flow of Control in Python

Q71. Write the output of the following:

a=10
while a>5:
   if a%7==0:
       print(a**2,end='@')
   else:
       print(a-1,end='@')
   a=a-3

a. 9@7@49@

b. 9@49@

c. 9@49

d. 9@7@5@

Q72. How many times the following loop will execute?

s1="flow of control in python"
for i in s1[1:5]:
   print()

a. 5

b. 4

c. 3

d. 2

Q73. Write the output of the following:

s=0
L = [2, 4, 6, 8, 10]
for i in range(1,len(L),1):
   s = s + L[i]
print(s)

a. 28

b. 30

c. 24

d. 26

Q74. How many times “Hello” will print:

s=0
L = [2, 4, 6, 8, 10]
for i in range(len(L)-1):
     print("Hello")
print("Hello")

a. 4

b. 3

c. 5

d. 6

Q75. How many times “Bye” will print:

s=0
L = [2, 4, 6, 8, 10]
for i in range(len(L)):
    if L[i]//2==1:
        print("Bye")

a. 4

b. 3

c. 2

d. 1

Q76. Write the output of the following:

L = ["A","B","C","D","E"]
for i in range(len(L)-2):
    L.pop()
print(L)

a. [‘A’, ‘B’, ‘C’]

b. [ ]

c. [‘A’, ‘B’]

d. [‘A’, ‘C’, ‘E’]

Q77. Write the output of the following:


def ch(st):
   str =""
   for i in range(1,4):
      if i%2==0:
         str=str+st[i]
      elif st[i].lower():
         str = str + st[i-1]
      else:
         str=str+st[i]
   print('-'. join (str))
ch('flow')

a. -f-o-o

b. -f-o-o-

c. f-o-o-

d. -f-o-

Q78. Write the output of the following:

st1="Flow91"
st2="gun"
I=0
while I<len(st1):
   if st1[I]>="a" and st1[I]<="z":
      st2=st2+st1[I+1]
   elif st1[I]>="0" and st1[I]<="9":
      st2=st2+st1[I-1]
   else:
      st2=st2+"?"
   I=I+1
print(st2)

a. gun?ow9w

b. gun?ow9w9

c. gun??w9w9

d. gun?ow9w?

Q79. Write the output of the following:

T=["flow","of","Control"]
T1=range(len(T))
for i in T1:
    print(T[i].upper(), end="-")

a. FLOW-OF-CONTROL-

b. FLOW-OF-CONTROL

c. -FLOW-OF-CONTROL

d. FLOWOFCONTROL

Q80. Write the output of the following:

d = [1, 2, 3]
for k in d:
   print(k, end = "+")
else:
   print("final")

a. 1+2+3+

b. 1+2+3+final+

c. 1+2+3+final

d. 6+final

Flow of Control in Python


Click here to check your performance in Flow of Control in Python MCQ

Flow of Control in Python

Q81. Syntax of ‘for’ loop is given below:

for < _________ > in <sequence/ items in range>:

Fill in the blank

a. control-variable

b. central-variable

c. center-variable

d. repeater-variable

Q82. Which of the following statement is not correct about ‘for’ loop?

a. The ‘for’ loop is used to iterate over a range of values or a sequence.

b. The ‘for’ loop is executed for each of the items in the range.

c. While using ‘for’ loop, it is known in advance the number of times the loop will execute

d. None of the above

Q83. _________ function is used in for loops for generating a sequence of numbers.

a. update( )

b. len( )

c. range( )

d. pop( )

Q84. Which of the following parameter of range( ) function is optional?

a. Start

b. Step

c. Both of the above

d. Stop

Q85. ________ statement terminates the current loop and resumes execution of the statement following that loop.

a. Continue

b. Break

c. Exit

d. Quit

Q86. _______________ statement skips the execution of remaining statements inside the body of the loop for the current iteration and jumps to the beginning of the loop for the next iteration

a. Continue

b. Break

c. Pass

d. Quit

Q87. A loop inside another loop is called ______

a. inner loop

b. nested loop

c. rest loop

d. None of the above

Q88. If the condition of the while loop is initially false, then the loop will execute ___

a. One time only

b. Three times only

c. Two times only

d. Zero time

Q89. Write the output of the following :

for x in range(1,4):
   for y in range(2,5):
      if x * y > 10:
         break
      print (x * y, end=" ")

a. 2 3 4 4 6 8 6

b. 2 3 4 4 6 8 6 9

c. 3 4 4 6 8 6 9

d. 2 3 4 4 6 8 6 9 9

Q90. Write the output of the following:

var = 7
while var > 0:
   print ('Current variable value: ', var)
   var = var -1
   if var == 3:
      break
   else:
      if var == 6: 
         var = var -1
         continue
   print ("Good bye!")
a. 

Current variable value: 7
Current variable value: 5
Good bye!
Current variable value: 4
b. 

Current variable value: 7
Current variable value: 5
Current variable value: 4
c. 

Current variable value: 7
Current variable value: 6
Current variable value: 5
Current variable value: 4
d. 

Current variable value: 7
Good bye!
Current variable value: 5
Current variable value: 4

Flow of Control in Python


Click here to check your performance in Flow of Control in Python MCQ

Flow of Control in Python

Q91. Execution of which statement is not dependent on the condition?

if i <=4 :
    print("Hello")     #Statement 1
    print("How")     #Statement 2
else:
    print("are")       #Statement 3
print("You")          #Statement 4

a. Statement 1

b. Statement 2

c. Statement 3

d. Statement 4

Q92. Which of the following statement will return error?

a. for i in a : #a is a list

b. for i in range(5) :

c. for i not in a : # a is a list

d. for i in (1, 2, 3) :

Q93. How many times the following loop will execute?

a = [10, 11, 12, 13, 45]
for a[3] in a:
     print("Flow")

a. 5

b. 13

c. 12

d. 6

Q94. Write the output of the following:

for l in range(3):
   if l == 2:
      continue
   else:
      print("i",end = " ")
else:
   print("Here")

a. i i i Here

b. i i Here

c. i i i

d. i i Here i

Q95. Which of the following is an empty statement in python?

a. Pass

b. Continue

c. Break

d. Exit

Q96. Which of the following is jump statement in python?

a. Pass

b. Continue

c. Break

d. Break and Continue

Q97. Which symbol is used to end loop and conditional statements?

a. Semicolon(;)

b. Comma(,)

c. Colon(:)

d. Exclamation(!)

Q98. Write the output of the following:

St="Amit"
for i in St:
   St.swapcase()
print(St)

a. Amit

b. aMIT

c. aMiT

d. AMit

Q99. What will be the value of ‘m’ and ‘n’ after execution of following code:

m = 3;
for n in range(2, 7, 2):
    n *= m
    n = n-1

a. 3 and 15

b. 3 and 17

c. 5 and 17

d. 5 and 15

Q100. What will be the value of ‘n’ and ‘n1’ after execution of following code:

n1=10
for n in range(10, 12):
    n1=n ** 2
    n1=n1-10

a. 111 and 11

b. 11 and 12

c. 11 and 111

d. 12 and 11

Flow of Control in Python


Click here to check your performance in Flow of Control in Python MCQ

Flow of Control in Python

Q101. Write the output of the following:

k = 5
sk = 0;
while k <= 12:
    sk = sk + k
    k = k + 4
print(sk, k)

a. 14 14

b. 13 14

c. 14 13

d. 13 13


Important Links

100 Practice Questions on Python Fundamentals

120+ MySQL Practice Questions

90+ Practice Questions on List

50+ Output based Practice Questions

100 Practice Questions on String

70 Practice Questions on Loops

120 Practice Questions of Computer Network in Python

70 Practice Questions on if-else

40 Practice Questions on Data Structure

Python Functions MCQ Class 12 CS

Computer Science Syllabus 2021-2022.

Informatics Practices Syllabus 2021-2022

Class 12 Computer Science Chapter wise MCQ


Share with others

Leave a Reply

error: Content is protected !!