0
0
Pythonprogramming~10 mins

Elif ladder 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
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 '>' will check for negative numbers.
Using '==' checks only if number equals zero, not positive.
2fill in blank
medium

Complete the code to print "Zero" when num is zero.

Python
if num > 0:
    print("Positive")
elif num [1] 0:
    print("Zero")
Drag options to blanks, or click blank then click option'
A>
B==
C!=
D<
Attempts:
3 left
💡 Hint
Common Mistakes
Using '!=' will check for any number except zero.
Using '<' or '>' will not correctly identify zero.
3fill in blank
hard

Fix the error in the elif condition to check if num is negative.

Python
if num > 0:
    print("Positive")
elif num [1] 0:
    print("Negative")
Drag options to blanks, or click blank then click option'
A<
B==
C>
D!=
Attempts:
3 left
💡 Hint
Common Mistakes
Using '==' checks only for zero, not negative numbers.
Using '!=' checks for any number except zero, not specifically negative.
4fill in blank
hard

Fill both blanks to complete the elif ladder that prints the sign of num.

Python
if num [1] 0:
    print("Positive")
elif num [2] 0:
    print("Negative")
Drag options to blanks, or click blank then click option'
A>
B<
C==
D!=
Attempts:
3 left
💡 Hint
Common Mistakes
Swapping the operators will give wrong results.
Using '==' in these places will not check for positive or negative.
5fill in blank
hard

Fill all three blanks to complete the elif ladder that prints the sign or zero.

Python
if num [1] 0:
    print("Positive")
elif num [2] 0:
    print("Negative")
else:
    print("[3]")
Drag options to blanks, or click blank then click option'
A>
B<
CZero
DPositive
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong operators in conditions.
Printing wrong string in else block.