Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete 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'
Attempts:
3 left
💡 Hint
Common Mistakes
Using '<' instead of '>' will check for negative numbers.
Using '==' checks only if number equals zero, not positive.
✗ Incorrect
The condition num > 0 checks if the number is positive.
2fill in blank
mediumComplete 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'
Attempts:
3 left
💡 Hint
Common Mistakes
Using '!=' will check for any number except zero.
Using '<' or '>' will not correctly identify zero.
✗ Incorrect
The condition num == 0 checks if the number is exactly zero.
3fill in blank
hardFix 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'
Attempts:
3 left
💡 Hint
Common Mistakes
Using '==' checks only for zero, not negative numbers.
Using '!=' checks for any number except zero, not specifically negative.
✗ Incorrect
The condition num < 0 correctly checks if the number is negative.
4fill in blank
hardFill 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'
Attempts:
3 left
💡 Hint
Common Mistakes
Swapping the operators will give wrong results.
Using '==' in these places will not check for positive or negative.
✗ Incorrect
The first condition checks if num > 0 for positive numbers.
The second checks if num < 0 for negative numbers.
5fill in blank
hardFill 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'
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong operators in conditions.
Printing wrong string in else block.
✗ Incorrect
The code checks if num > 0 for positive, num < 0 for negative, and prints "Zero" otherwise.