0
0
Pythonprogramming~10 mins

Arithmetic operators 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 add two numbers and print the result.

Python
result = 5 [1] 3
print(result)
Drag options to blanks, or click blank then click option'
A+
B-
C*
D/
Attempts:
3 left
💡 Hint
Common Mistakes
Using '-' will subtract instead of add.
Using '*' or '/' will multiply or divide, not add.
2fill in blank
medium

Complete the code to multiply two numbers and print the result.

Python
result = 7 [1] 4
print(result)
Drag options to blanks, or click blank then click option'
A*
B+
C-
D/
Attempts:
3 left
💡 Hint
Common Mistakes
Using '+' adds numbers instead of multiplying.
Using '/' divides numbers, not multiply.
3fill in blank
hard

Fix the error in the code to correctly divide two numbers and print the result.

Python
result = 10 [1] 2
print(result)
Drag options to blanks, or click blank then click option'
A+
B*
C/
D-
Attempts:
3 left
💡 Hint
Common Mistakes
Using '*' multiplies instead of dividing.
Using '+' or '-' changes the operation to addition or subtraction.
4fill in blank
hard

Fill both blanks to create a dictionary of squares for numbers greater than 3.

Python
squares = {x: x[1]2 for x in range(1, 6) if x [2] 3}
print(squares)
Drag options to blanks, or click blank then click option'
A**
B+
C>
D-
Attempts:
3 left
💡 Hint
Common Mistakes
Using '+' instead of '**' will add 2 instead of squaring.
Using '<' instead of '>' will select numbers less than 3.
5fill in blank
hard

Fill all three blanks to create a dictionary of uppercase keys and values greater than zero.

Python
result = [1]: [2] for k, v in data.items() if v [3] 0}
Drag options to blanks, or click blank then click option'
Ak.upper()
Bv
C>
Dk
Attempts:
3 left
💡 Hint
Common Mistakes
Using k instead of k.upper() keeps keys lowercase.
Using '<' instead of '>' filters wrong values.