Multiple Choice Question For Flow of Control Class 11 Computer Science (CS), Informatics Practices (IP)
1. In a Python program, a control structure:
(a) directs the order of execution of the statements in the program.
(b) dictates what happens before the program starts and after it terminates.
(c) defines program-specific data structures
(d) manages the input and output of control characters
2. An empty/null statement in Python is _____.
(a) go
(b) pass
(c) over
(d) ;
3. The order of statement execution in the form. of top to bottom, is known _____ as construct.
(a) selection
(b) repetition
(c)sequence
(d) flow
4. The _____ construct allows to choose statements to be executed, depending upon the result of a condition.
(a) selection
(b) repetition
(c)sequence
(d) flow
5. The _____ construct repeats a set of statements a specified number of times or as ng as a condition is true.
(a) selection
(b) repetition
(c)sequence
(d) flow
6. Which of the following statements will make a selection construct?
(a) if
(b) if-else
(c) for
(d) while
7. Which of the following statements will make a repetition construct?
(a) if
(b) if-else
(c) for
(d) while
8. In Python, which of the following will create a block in a compound statement ?
(a) colon
(b) statements indented at a lower, same level
(c) indentation in any form
(d) { }
9. What signifies the end of a statement block or suite in Python?
(a) A comment
(b) }
(c) end
(d) A line that is indented less than the previous line
10. Which one of the following if statements will not execute successfully?
(a)
if (1, 2) :
print('foo')
(b)
if (1, 2)
print('foo')
(c)
if (1, 2) :
print('foo')
(d)
if (1):
print('foo')
11. What does the following Python program display?
x = 3
if x == 8:
print ("Am I here?", end = '')
elif x == 3:
print("Or here?", end = "")
else:
pass
print ("Or over here?")
(a) Am I here?
(b) Or here?
(c) Am I here? Or here?
(d) Or here? Or over here ?
(e) Am I here? Or over here?
12. If the user inputs: 2
x = float(input())
if(x == 1):
print("Yes")
elif (x >= 2):
print("Maybe")
else:
print ("No")
(a) Yes
(b) No
(c) Maybe
(d) Nothing is printed
(e) Error
Consider the following code segment for the questions 13-17:
a = int(input("Enter an integer: ")) b = int(input("Enter an integer: ")) if a <= 0: b = b + 1 else: a = a + 1 if a > 0 and b > 0: print("W") elif a > 0: print("X") if b > 0: print("Y") else: print("Z")
13. What letters will be printed if the user enters 0 for a and 0 for b?
(a) Only W
(b) Only X
(d) W and X
(c) Only Y
(e) W, X and Y
14. What letters will be printed if the user enter; for a and 1 for b ?
(a) W and X
(b) W and Y
(c) X and Y
(d) X and Z
(e) W, X and Y
15. What letters will be printed if the user enter 1 for a and -1 for b?
(a) W and X
(b) X and Y
(c) Y and Z
(d) X and Z
(e) W and Z
16. What letters will be printed if the user enter 1 for a and 0 for b?
(a) W and X
(b) X and Y
(c) Y and Z
(d) X and Z
(e) W and Z
17. What letters will be printed if the user enter -1 for a and -1 for b?
(a) Only W
(b) Only X
(c) Only Y
(d) Only Z
(e) No letters are printed
18. What values are generated when the function range(6, 0, -2) is executed?
(a) [4, 2]
(b) [4, 2, 0]
(c) [6, 4, 2]
(d) [6, 4, 2, 0]
(e) [6, 4, 2, 0, -2]
19. Which of the following is not a valid loop a in Python ?
(a) for
(b) while
(c) do-while
(d) if-else
20. Function range(3) is equivalent to :
(a) range(1, 3)
(b) range(0, 3)
(c) range(0, 3, 1)
(d) range(1, 3, 0)
21. Function range(3) will yield an iteratable sequence like
(a) [0, 1, 2]
(b) [0, 1, 2, 3]
(c) [1, 2, 3]
(d) [0, 2]
22. Function range(0, 5, 2) will yield on iteratable sequence like
(a) [0, 2, 4]
(b) [1, 3, 5]
(c) [0, 1, 2, 5]
(d) [0, 5, 2]
23. Function range(10, 5, -2) will yield an iteratable sequence like
(a) [10, 8, 6]
(b) [9, 7, 5]
(c) [6, 8, 10]
(d) [5, 7, 9]
24. Function range(10, 5, 2) will yield an iteratable sequence like
(a) [ ]
(b) [10, 8, 6]
(c) [2, 5, 8]
(d) [8, 5, 2]
25. Consider the loop given below:
for i in range(-5):
print (i)
How many times will this loop run?
(a) 5
(b) 0
(c) infinite
(d) Error
26. Consider below:
for i in range(10, 5, -3):
print (i)
How many times will this loop run ?
(a) 3
(b) 2
(c) 1
(d) infinite
27. Consider the loop given below:
for i in range (3):
pass
What will be the final value of i after this loop?
(a) 0
(b) 1
(c) 2
(d) 3
28. Consider the loop given below:
for i in range (7, 4,-2):
break
What will be the final value of i after this loop?
(a) 4
(b) 5
(c) 7
(d) -2
29. In for a in _____:, the blank can be filled with
(a) an iterable sequence
(b) a range() function
(c) a single value
(d) an expression
30. Consider the following code segment:
for i in range (2, 4):
print (i)
What values(s) are printed when it executes ?
(a) 2
(b) 3
(c) 2 and 3
(d) 3 and 4
(e) 2, 3 and 4
31. What is the output produced when this code executes ?
for i in range(4,8):
if i % 2 == 0:
a = a + i
print(a)
(a) 4
(b) 8
(c) 10
(d) 18
32. Which of the following code segments contain an example of a nested loop ?
(a)
for i in range (10):
print (i)
for j in range (10):
print (j)
(b)
for i in range (10):
print(i)
for j in range(10):
print(j)
(c)
for i in range(10):
print(i)
for i in range(20):
print (i)
i = i + 1
(d)
for i in range(10):
print(i)
for i in range(20):
print (i)
33. Which of the following statement(s) will terminate the whole loop and proceed to the statement following the loop?
(a) pass
(b) break
(c) continue
(d) goto
34. Which of the following statement(s) will terminate only the current pass of the loop and proceed with the next iteration of the loop?
(a) pass
(b) break
(c) continue
(d) goto
35 Which of the following are entry controlled loops ?
(a) if
(b) if-else
(c) for
(d) while
36. Consider the loop given below. What will be the final value of i after the loop ?
for i in range (10):
break
(a) 10
(b) 0
(c) Error
(d) 9
37. The else statement can be a part of _____ statement in Python.
(a) if
(b) def
(c) while
(d) for
38 Which of the following are jump statements ?
(a) if
(b) break
(c) while
(d) continue
39. Consider the following code segment :
for i in range (2, 4) :
print(i)
What values(s) are printed when it executes ?
(a) 2
(b) 3
(c) 2 and 3
(d) 3 and 4
(e) 2, 3 and 4
40. When the following code runs, how many times is the line executed ? "x = x * 2"
x = 1
while (x < 20) :
x = x * 2
(a) 2
(b) 5
(c) 19
(d) 4
(e) 32
41. What is the output when this code executes ?
x = 1
while (x <= 5) :
x + 1
print (x)
(a) 6
(b) 1
(c) 4
(d) 5
(e) no output
42. How many times does the following code execute ?
x = 1
while (x <= 5) :
x + 1
print (x)
(a) 6
(b) 1
(c) 4
(d) 5
(e) infinite
43. What is the output produced when this code executes ?
i = 1
while (i <= 7) :
i * = 2
print (i)
(a) 8
(b) 16
(c) 4
(d) 14
(e) no output
44. Consider the following loop:
j = 10
while j >= 5 :
print("X")
j = j - 1
Which of the following for loops will generate the same output as the loop shown previously?
(a)
for j in range (- 1, - 5, - 1) :
print (“X”)
(b)
for j in range (0, 5) :
print("X”)
(c)
for j in range (10, - 1, - 2) :
print("X")
(d)
for j in range (10, 5) :
print("X")
(e)
for j in range (10, 5, - 1) :
print("X")
45. 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)
(a) 4
(b) 8
(c) 10
(d) 18
46. Which of the following code segments contain an example of a nested loop?
(a)
for i in range (10):
print(i)
for j in range (10):
print (j)
(b)
for i in range (10):
print (i)
for j in range (10) :
print( j)
(c)
for i in range (10):
print (i)
while i < 20 :
print(i)
i = i + 1
(d)
for i in range (10):
print(i)
while i < 20 :
print (i)
Don't give wrong answers question18
ReplyDeleteSorry,
Deletex==thanks
ReplyDeleteprint(x)
x = Welcome
Deleteprint(x," : ) ")
Answer of question no. 18 and 44 are wrong
ReplyDeleteThank you telling us : ), We have corrected it.
DeletePost a Comment
You can help us by Clicking on ads. ^_^
Please do not send spam comment : )