Python Flow Control (if else and loops) Quiz

Control Flow Quiz

Python Control Flow (If else and loops) Quiz

Topics covered in this quiz :

  1. Python if else
  2. Python For Loop
  3. Python While Loop
  4. Python Ternary Operator
  5. Python Break
  6. Python Continue

1) What is the output of the following code:
x = 0
for i in range(2, 6):
if i % 2 == 0:
x = x + i
print(x)

2) What is the output of the following code:
x = 1
while(x <= 4):
x + 2
print(x)

3) In Python, we have the following jump statements:

4) Which statement will make repetition construct?

5) What is the final value of 'i'?
for i in range(4):
break

6) Which of the following is the entry control loop in Python?

7) What is the output of the following code:
x = 1
while(x <= 4):
x = x + 1
print(x)

8) What is the equivalent of range(4)?

9) What is the value of i after this loop?
for i in range(8,4,-2):
break

10) Which statement will make selection construct?

11) Which statement cannot have else statement in Python?

12) What is the final value of i after this loop?
for i in range(4):
pass

13) What is the output of the following code:
for i in range(1,3):
print(i)

14) How many times the below loop will run?
for i in range(8,4,-2):
print(i)

15) Which statement is used to terminate the current iteration of the loop?

16) Which statement is used to terminate the whole loop?

17) What values will this code generate:
range(8,0,-2)

Your score is

The average score is 0%

0%