0
0
Pythonprogramming~10 mins

Nested conditional execution 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 check if a number is positive.

Python
num = 5
if num [1] 0:
    print("Positive number")
Drag options to blanks, or click blank then click option'
A==
B<
C>
D!=
Attempts:
3 left
💡 Hint
Common Mistakes
Using '<' instead of '>' which checks for negative numbers.
Using '==' which only checks if the number is exactly zero.
2fill in blank
medium

Complete the code to check if a number is positive and even.

Python
num = 4
if num > 0 and num [1] 2 == 0:
    print("Positive even number")
Drag options to blanks, or click blank then click option'
A%
B//
C**
D+
Attempts:
3 left
💡 Hint
Common Mistakes
Using '//' which does floor division instead of checking remainder.
Using '+' or '**' which are not related to divisibility.
3fill in blank
hard

Fix the error in the nested if statement to check if a number is positive and less than 10.

Python
num = 7
if num > 0:
    if num [1] 10:
        print("Number is positive and less than 10")
Drag options to blanks, or click blank then click option'
A>
B==
C!=
D<
Attempts:
3 left
💡 Hint
Common Mistakes
Using '>' which checks if number is greater than 10.
Using '==' which checks equality, not less than.
4fill in blank
hard

Fill both blanks to print if a number is positive and even.

Python
num = 8
if num [1] 0:
    if num [2] 2 == 0:
        print("Positive even number")
Drag options to blanks, or click blank then click option'
A>
B<
C%
D//
Attempts:
3 left
💡 Hint
Common Mistakes
Using '<' for positive check which is incorrect.
Using '//' instead of '%' for even check.
5fill in blank
hard

Fill all three blanks to print if a number is positive, even, and less than 20.

Python
num = 16
if num [1] 0:
    if num [2] 2 == 0:
        if num [3] 20:
            print("Positive even number less than 20")
Drag options to blanks, or click blank then click option'
A>
B%
C<
D==
Attempts:
3 left
💡 Hint
Common Mistakes
Using '==' instead of '<' for the last condition.
Using '//' instead of '%' for even check.