0
0
Pythonprogramming~10 mins

If–else execution flow in Python - Interactive Code Practice

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

Complete the code to print "Yes" if the number is greater than 10.

Python
number = 15
if number [1] 10:
    print("Yes")
Drag options to blanks, or click blank then click option'
A<
B<=
C>
D==
Attempts:
3 left
💡 Hint
Common Mistakes
Using < instead of > will check the wrong condition.
2fill in blank
medium

Complete the code to print "Even" if the number is divisible by 2.

Python
number = 8
if number [1] 2 == 0:
    print("Even")
Drag options to blanks, or click blank then click option'
A%
B//
C**
D+
Attempts:
3 left
💡 Hint
Common Mistakes
Using // will do floor division, not remainder.
3fill in blank
hard

Fix the error in the if statement to check if age is at least 18.

Python
age = 20
if age [1] 18:
    print("Adult")
Drag options to blanks, or click blank then click option'
A>=
B<=
C=>
D==
Attempts:
3 left
💡 Hint
Common Mistakes
Using => is a syntax error in Python.
4fill in blank
hard

Fill both blanks to print "Positive" if x is greater than 0 and "Non-positive" otherwise.

Python
x = 5
if x [1] 0:
    print("Positive")
else:
    print("[2]")
Drag options to blanks, or click blank then click option'
A>
BNegative
CNon-positive
D<
Attempts:
3 left
💡 Hint
Common Mistakes
Using < instead of > will reverse the logic.
Printing "Negative" is not correct because zero is also non-positive.
5fill in blank
hard

Fill all three blanks to print "Fizz" if number divisible by 3, "Buzz" if divisible by 5, else print the number.

Python
number = 15
if number [1] 3 == 0:
    print("[2]")
elif number [3] 5 == 0:
    print("Buzz")
else:
    print(number)
Drag options to blanks, or click blank then click option'
A%
BFizz
C==
D//
Attempts:
3 left
💡 Hint
Common Mistakes
Using // instead of % will not check divisibility correctly.