0
0
Pythonprogramming~10 mins

Assignment and augmented assignment 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 value 10 to the variable x.

Python
x [1] 10
Drag options to blanks, or click blank then click option'
A=
B==
C+=
D:=
Attempts:
3 left
💡 Hint
Common Mistakes
Using '==' which is for comparison, not assignment.
Using '+=' when you just want to assign a value.
2fill in blank
medium

Complete the code to add 5 to the variable count using augmented assignment.

Python
count [1] 5
Drag options to blanks, or click blank then click option'
A=
B+=
C-=
D*=
Attempts:
3 left
💡 Hint
Common Mistakes
Using '=' which replaces the value instead of adding.
Using '-=' which subtracts instead of adding.
3fill in blank
hard

Fix the error in the code to multiply the variable total by 3 using augmented assignment.

Python
total [1] 3
Drag options to blanks, or click blank then click option'
A*=
B*
C=
D**
Attempts:
3 left
💡 Hint
Common Mistakes
Using '*' which only multiplies but does not assign.
Using '=' which replaces the value without multiplying.
4fill in blank
hard

Complete the code to subtract 2 from score using augmented assignment.

Python
score [1] 2
Drag options to blanks, or click blank then click option'
A=
B+=
C-=
D*=
Attempts:
3 left
💡 Hint
Common Mistakes
Using '+=' instead of '-=' for subtraction.
Using '*' or '+=' which do not subtract.
5fill in blank
hard

Fill all three blanks to create a variable new_value that adds 4 to old_value and then multiplies by 2.

Python
new_value [1] old_value [2] 4
new_value [3] 2
Drag options to blanks, or click blank then click option'
A=
B+
C*=
D*
Attempts:
3 left
💡 Hint
Common Mistakes
Using '+=' in the first line instead of '='.
Using '*' instead of '*=' in the last line.