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   


Python Basics MCQs - Set 1 Answer

Python Basics MCQs Set-1 Answers



Top of Form
Question 1. The _______ are names given to some data or information that we want to store in a Python programs.
A. variables
B. tokens
C. keywords
D. none of these

ANSWER: A. variables



Question 2. Which of the following character can be used to specify comments in Python?
A. #
B. $
C. //
D. none of these

ANSWER: A. #



Question 3. The _______are used to describe the code and are not interpreted by Python.
A. variables
B. comments
C. tokens
D. loops

ANSWER: B. comments



Question 4. A variable name cannot start with a __________.
A. number
B. letter
C. underscore
D. none of these

ANSWER: A. number



Question 5. Which of the following is invalid identifier name?
A. _num
B. Num
C. 101_
D. Syntax

ANSWER: C. 101_



Back to Python MCQs >