Sunday, 12 April 2020

Python if else MCQs Set 1 Answer

Python if else MCQs Set 1 Answer




Question 1. If the Boolean expression of if statement evaluates to ________, then the block of code inside the if statement will be ignored.
A. True
B. False
C. both True and False
D. none of these
ANSWER: B. False 

Question 2. Predict output of the following python program.
a, b, c = 5, 1, 15

if (a < b) and (a < c):
  print("A is minimum")
elif (b < a) and (b < c):
  print("B is minimum")
else:
  print("C is minimum")
A. A is minimum
B. B is minimum
C. C is minimum
D. none of these
ANSWER: B. B is minimum 

Question 3. Predict output of following python code:
if(4-6):
   print("Android")
else:
   print("Linux")


A. Android
B. Linux
C. Error
D. none of these
ANSWER: A. Android 

Question 4. What will be the output of the following python program?

    if False:
       print ("AAA")
    elif True:
       print ("BBB")
    else:
       print ("CCC")

A. AAA
B. BBB
C. CCC
D. none of these
ANSWER: B. BBB  

Question 5. What will be the output of the following python program?


    result = 50
    if(result != 50):
       flag=0
    else:
       flag=1
    if(flag==0):
       print("Pass")
    else:
       print("Fail")

A. Pass
B. Fail
C. Syntax Error
D. none of these
ANSWER: B. Fail   


No comments:

Post a Comment