0
0
Pythonprogramming~10 mins

Boolean values (True and False) 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 assign the Boolean value True to the variable.

Python
is_active = [1]
Drag options to blanks, or click blank then click option'
ATrue
Btrue
C1
D"True"
Attempts:
3 left
💡 Hint
Common Mistakes
Using lowercase 'true' instead of 'True'.
Using the string "True" instead of the Boolean True.
2fill in blank
medium

Complete the code to check if the variable is False.

Python
if is_ready == [1]:
    print("Not ready")
Drag options to blanks, or click blank then click option'
AFalse
Bfalse
C"False"
D0
Attempts:
3 left
💡 Hint
Common Mistakes
Using lowercase 'false' instead of 'False'.
Comparing to the string "False" instead of the Boolean False.
3fill in blank
hard

Fix the error in the code to correctly assign a Boolean value.

Python
is_valid = [1]
Drag options to blanks, or click blank then click option'
A1
Btrue
C"true"
DTrue
Attempts:
3 left
💡 Hint
Common Mistakes
Using lowercase 'true' instead of 'True'.
Using the string "true" instead of the Boolean True.
4fill in blank
hard

Fill both blanks to create a Boolean expression that checks if x is True and y is False.

Python
if x == [1] and y == [2]:
    print("Condition met")
Drag options to blanks, or click blank then click option'
ATrue
BFalse
Ctrue
Dfalse
Attempts:
3 left
💡 Hint
Common Mistakes
Using lowercase 'true' or 'false'.
Using strings instead of Boolean values.
5fill in blank
hard

Fill all three blanks to create a dictionary with Boolean values as keys and strings as values.

Python
status = [1]: "On", [2]: "Off", [3]: "Unknown"}
Drag options to blanks, or click blank then click option'
A{True
BFalse
CNone
DTrue
Attempts:
3 left
💡 Hint
Common Mistakes
Missing the opening curly brace.
Using lowercase Boolean values.
Using strings instead of Boolean or None.