Python Programming Multiple Choice Question -
Conditionals And Loops
This section focuses on the "Conditionals And Loops" of the Python programming. These Multiple Choice Questions (mcq) should be practiced to improve the Python programming skills required for various interviews (campus interview, walk-in interview, company interview), placement, entrance exam and other competitive examinations.
1. Which one of the following is a valid Python if statement :
Explanation: If statment always ended with colon (:)
2. What keyword would you use to add an alternative condition to an if statement?
Explanation: elif is used to add an alternative condition to an if statment.
3. Can we write if/else into one line in python?
Explanation: Yes, we can write if/else in one line. For eg
i = 5 if a > 7 else 0
4. In a Python program, a control structure:
Explanation: Control structures determine which statements in the program will be executed and in what order, allowing for statements to be skipped over or executed repeatedly.
5. What will be output of this expression:
'p' + 'q' if '12'.isdigit() else 'r' + 's'
Explanation: If condition is true so pq will be the output.
6. Which statement will check if a is equal to b?
7. Does python have switch case statement?
Also check :