Quiz Control Flow

Python Quiz : Python Control Flow – 04

Python Quiz for Control Flow

Welcome to the “Python Quiz for Control Flow”! Mastering control flow structures is a pivotal step in one’s journey to become a proficient Python programmer. This quiz is designed to test your understanding of if-else logic, conditional statements, loops, and other control flow mechanisms in Python. Whether you’re a beginner looking to solidify your foundational knowledge or seeking a quick refresher, this quiz is tailored to challenge and reinforce your grasp on these essential constructs.

Prepare for the quiz: control flow methods

0%
6

Python Control Flow – 04

Level: Beginner

1 / 10

1. What is the output of the following code?

for i in range(5):
  if i == 3:
    continue
  print(i)

2 / 10

2. What is the output of the following code? “`it = iter([1, 2, 3]); print(next(it, ‘Done’))“`

3 / 10

3. What is the output of the following code?

it = iter([1, 2, 3])
print(next(it))
print(next(it))
print(next(it))
print(next(it))

 

4 / 10

4. What is the output of the following code?

def gen():
  yield 1
  yield 2
  yield 3
g = gen()
print(list(g))

5 / 10

5. Which method is used to get the next value from an iterator?

6 / 10

6. What is the output of the following code?

def gen():
  yield 1
  yield 2
g = gen()
print(next(g))
print(next(g))
print(next(g))

7 / 10

7. Which of the following is used to define a generator function?

8 / 10

8. What is the output of the following code?

def gen():
  yield 1
  yield 2
g = gen()
print(next(g))
print(next(g))

9 / 10

9. What is the output of the following code?

def gen():
    yield 1
    yield 2
g = gen()
print(next(g, 'Done'))

10 / 10

10. What is the output of the following code? “`it = iter([1, 2, 3]); print(next(it)); print(next(it)); print(next(it))“`

Your score is

0%