Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to assign an integer value to the variable.
Python
x = [1] Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using quotes around numbers makes them strings.
Using decimal points makes the number a float.
✗ Incorrect
The variable x is assigned the integer value 10.
2fill in blank
mediumComplete the code to change the variable to a string value.
Python
x = [1] Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Forgetting quotes around text.
Using numbers without quotes when a string is needed.
✗ Incorrect
The variable x is now assigned the string value "world".
3fill in blank
hardFix the error in the code to assign a float value to the variable.
Python
x = [1] Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using commas instead of dots for decimals.
Putting numbers in quotes makes them strings.
✗ Incorrect
The variable x is assigned the float value 3.14 without quotes or commas.
4fill in blank
hardFill both blanks to create a variable that changes from integer to boolean.
Python
x = [1] x = [2]
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using quotes around True or False makes them strings.
Assigning a string instead of an integer first.
✗ Incorrect
First, x is assigned the integer 5. Then it changes to the boolean value True.
5fill in blank
hardFill all three blanks to show a variable changing from string to float to integer.
Python
x = [1] x = [2] x = [3]
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Keeping quotes when changing to float or integer.
Using 7.0 instead of 7 for the integer value.
✗ Incorrect
The variable x starts as a string "7.5", then changes to a float 7.5, and finally to an integer 7.