Multiple Choice Questions

Question 1

In a Python program, a control structure:

  1. directs the order of execution of the statements in the program ✓
  2. dictates what happens before the program starts and after it terminates
  3. defines program-specific data structures
  4. manages the input and output of control characters

Question 2

An empty/null statement in Python is

  1. go
  2. pass ✓
  3. over
  4. ;

Question 3

The order of statement execution in the form of top to bottom, is known as ………. construct.

  1. selection
  2. repetition
  3. sequence ✓
  4. flow

Question 4

The ………. construct allows to choose statements to be executed, depending upon the result of a condition.

  1. selection ✓
  2. repetition
  3. sequence
  4. flow

Question 5

The ………. construct repeats a set of statements a specified number of times or as long as a condition is true.

  1. selection
  2. repetition ✓
  3. sequence
  4. flow

Question 6

Which of the following statements will make a selection construct?

  1. if ✓
  2. if-else ✓
  3. for
  4. while

Question 7

Which of the following statements will make a repetition construct?

  1. if
  2. if-else
  3. for ✓
  4. while ✓

Question 8

In Python, which of the following will create a block in a compound statement ?

  1. colon
  2. statements indented at a lower, same level ✓
  3. indentation in any form
  4. { }

Question 9

What signifies the end of a statement block or suite in Python ?

  1. A comment
  2. }
  3. end
  4. A line that is indented less than the previous line ✓

Question 10

Which one of the following if statements will not execute successfully ?

  1. if (1, 2) :
        print(‘foo’)
  2. if (1, 2)
        print(‘foo’) ✓
  3. if (1, 2) :
    print(‘foo’) ✓
  4. 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?")
  1. Am I here?
  2. Or here?
  3. Am I here? Or here?
  4. Or here? Or over here? ✓
  5. 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")
  1. Yes
  2. No
  3. Maybe ✓
  4. Nothing is printed
  5. 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 ?

  1. Only W
  2. Only X
  3. Only Y ✓
  4. W and X
  5. 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 ?

  1. W and X
  2. W and Y ✓
  3. X and Y
  4. X and Z
  5. 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?

  1. W and X
  2. X and Y
  3. Y and Z
  4. X and Z ✓
  5. 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 ?

  1. W and X
  2. X and Y
  3. Y and Z
  4. X and Z ✓
  5. 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?

  1. Only W
  2. Only X
  3. Only Y
  4. Only Z ✓
  5. No letters are printed

Question 18

What values are generated when the function range(6, 0, -2) is executed ?

  1. [4, 2]
  2. [4, 2, 0]
  3. [6, 4, 2] ✓
  4. [6, 4, 2, 0]
  5. [6, 4, 2, 0, -2]

Question 19

Which of the following is not a valid loop in Python ?

  1. for
  2. while
  3. do-while ✓
  4. if-else ✓

Question 20

Which of the following statement(s) will terminate the whole loop and proceed to the statement following the loop ?

  1. pass
  2. break ✓
  3. continue
  4. goto

Discover more from EduGrown School

Subscribe to get the latest posts sent to your email.