Table of Contents
Multiple Choice Questions
Question 1
In a Python program, a control structure:
- directs the order of execution of the statements in the program ✓
- dictates what happens before the program starts and after it terminates
- defines program-specific data structures
- manages the input and output of control characters
Question 2
An empty/null statement in Python is
- go
- pass ✓
- over
- ;
Question 3
The order of statement execution in the form of top to bottom, is known as ………. construct.
- selection
- repetition
- sequence ✓
- flow
Question 4
The ………. construct allows to choose statements to be executed, depending upon the result of a condition.
- selection ✓
- repetition
- sequence
- flow
Question 5
The ………. construct repeats a set of statements a specified number of times or as long as a condition is true.
- selection
- repetition ✓
- sequence
- flow
Question 6
Which of the following statements will make a selection construct?
- if ✓
- if-else ✓
- for
- while
Question 7
Which of the following statements will make a repetition construct?
- if
- if-else
- for ✓
- while ✓
Question 8
In Python, which of the following will create a block in a compound statement ?
- colon
- statements indented at a lower, same level ✓
- indentation in any form
- { }
Question 9
What signifies the end of a statement block or suite in Python ?
- A comment
- }
- end
- A line that is indented less than the previous line ✓
Question 10
Which one of the following if statements will not execute successfully ?
- if (1, 2) :
print(‘foo’) - if (1, 2)
print(‘foo’) ✓ - if (1, 2) :
print(‘foo’) ✓ - if (1) :
print( ‘foo’ )
Question 11
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?")
- Am I here?
- Or here?
- Am I here? Or here?
- Or here? Or over here? ✓
- Am I here? Or over here?
Question 12
If the user inputs : 2<ENTER>, what does the following code snippet print?
x = float(input()) if(x==1): print("Yes") elif (x >= 2): print("Maybe") else: print ("No")
- Yes
- No
- Maybe ✓
- Nothing is printed
- Error
Question 13
Consider the following code segment:
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")
What letters will be printed if the user enters 0 for a and 0 for b ?
- Only W
- Only X
- Only Y ✓
- W and X
- W, X and Y
Question 14
Consider the following code segment:
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")
What letters will be printed if the user enters 1 for a and 1 for b ?
- W and X
- W and Y ✓
- X and Y
- X and Z
- W, X and Y
Question 15
Consider the following code segment:
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")
What letters will be printed if the user enters 1 for a and -1 for b?
- W and X
- X and Y
- Y and Z
- X and Z ✓
- W and Z
Question 16
Consider the following code segment:
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")
What letters will be printed if the user enters 1 for a and 0 for b ?
- W and X
- X and Y
- Y and Z
- X and Z ✓
- W and Z
Question 17
Consider the following code segment:
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")
What letters will be printed if the user enters -1 for a and -1 for b?
- Only W
- Only X
- Only Y
- Only Z ✓
- No letters are printed
Question 18
What values are generated when the function range(6, 0, -2) is executed ?
- [4, 2]
- [4, 2, 0]
- [6, 4, 2] ✓
- [6, 4, 2, 0]
- [6, 4, 2, 0, -2]
Question 19
Which of the following is not a valid loop in Python ?
- for
- while
- do-while ✓
- if-else ✓
Question 20
Which of the following statement(s) will terminate the whole loop and proceed to the statement following the loop ?
- pass
- break ✓
- continue
- goto
Discover more from EduGrown School
Subscribe to get the latest posts sent to your email.