0
0
Pythonprogramming~10 mins

Break vs continue execution difference in Python - Interactive Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to stop the loop when the number 3 is found.

Python
for num in range(5):
    if num == 3:
        [1]
    print(num)
Drag options to blanks, or click blank then click option'
Abreak
Bcontinue
Cpass
Dexit
Attempts:
3 left
💡 Hint
Common Mistakes
Using continue instead of break, which skips the rest of the loop but does not stop it.
2fill in blank
medium

Complete the code to skip printing the number 3 but continue the loop.

Python
for num in range(5):
    if num == 3:
        [1]
    print(num)
Drag options to blanks, or click blank then click option'
Acontinue
Bbreak
Cpass
Dstop
Attempts:
3 left
💡 Hint
Common Mistakes
Using break which stops the loop entirely instead of skipping one iteration.
3fill in blank
hard

Fix the error in the code to correctly skip even numbers and print only odd numbers.

Python
for num in range(1, 6):
    if num % 2 == 0:
        [1]
    print(num)
Drag options to blanks, or click blank then click option'
Apass
Bskip
Ccontinue
Dbreak
Attempts:
3 left
💡 Hint
Common Mistakes
Using break stops the loop too early, printing fewer numbers.
4fill in blank
hard

Fill both blanks to create a dictionary of squares for numbers less than 5, skipping number 3.

Python
squares = {x: x[1]2 for x in range(1, 7) if x [2] 5 and x != 3}
Drag options to blanks, or click blank then click option'
A**
B<
C>
D+
Attempts:
3 left
💡 Hint
Common Mistakes
Using + instead of ** for squaring, or > instead of < for filtering.
5fill in blank
hard

Fill all three blanks to create a dictionary of uppercase keys and values greater than 2.

Python
result = { [1]: [2] for k, v in data.items() if v [3] 2}
Drag options to blanks, or click blank then click option'
Ak.upper()
Bv
C>
Dk.lower()
Attempts:
3 left
💡 Hint
Common Mistakes
Using k.lower() instead of k.upper(), or using < instead of > for filtering.