## 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 of the following is not used as loop in Python?

A. for loop
B. while loop
C. do-while loop
D. None of the above

2. Which of the following is False regarding loops in Python?

A. Loops are used to perform certain tasks repeatedly.
B. While loop is used when multiple statements are to executed repeatedly until the given condition becomes False
C. While loop is used when multiple statements are to executed repeatedly until the given condition becomes True.
D. for loop can be used to iterate through the elements of lists.

3. Which of the following is True regarding loops in Python?

A. Loops should be ended with keyword "end".
B. No loop can be used to iterate through the elements of strings.
C. Keyword "break" can be used to bring control out of the current loop.
D. Keyword "continue" is used to continue with the remaining statements inside the loop.

4. How many times will the loop run?

```i=2
while(i>0):
i=i-1
```

A. 2
B. 3
C. 1
D. 0

5. What will be the output of the following Python code?

```list1 = [3 , 2 , 5 , 6 , 0 , 7, 9]
sum = 0
sum1 = 0
for elem in list1:
if (elem % 2 == 0):
sum = sum + elem
continue
if (elem % 3 == 0):
sum1 = sum1 + elem

print(sum , end=" ")
print(sum1)
```

A. 8 9
B. 8 3
C. 2 3
D. 8 12

6. Which one of the following is a valid Python if statement :

A. if a>=2 :
B. if (a >= 2)
C. if (a => 22)
D. if a >= 22

7. What keyword would you use to add an alternative condition to an if statement?

A. else if
B. elseif
C. elif
D. None of the above

8. Can we write if/else into one line in python?

A. Yes
B. No
C. if/else not used in python
D. None of the above

9. In a Python program, a control structure:

A. Defines program-specific data structures
B. Directs the order of execution of the statements in the program
C. Dictates what happens before the program starts and after it terminates
D. None of the above

10. What will be output of this expression:

`'p' + 'q' if '12'.isdigit() else 'r' + 's'`

A. pq
B. rs
C. pqrs
D. pq12

11. Which statement will check if a is equal to b?

A. if a = b:
B. if a == b:
C. if a === c:
D. if a == b

12. Does python have switch case statement?

A. True
B. False
C. Python has switch statement but we can not use it.
D. None of the above

Also check :

Discussion