0
0
Pythonprogramming~10 mins

How variable type changes at runtime in Python - Interactive Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to assign an integer value to the variable.

Python
x = [1]
Drag options to blanks, or click blank then click option'
A10
B3.14
C"hello"
DTrue
Attempts:
3 left
💡 Hint
Common Mistakes
Using quotes around numbers makes them strings.
Using decimal points makes the number a float.
2fill in blank
medium

Complete the code to change the variable to a string value.

Python
x = [1]
Drag options to blanks, or click blank then click option'
A100
B"world"
CFalse
D3.5
Attempts:
3 left
💡 Hint
Common Mistakes
Forgetting quotes around text.
Using numbers without quotes when a string is needed.
3fill in blank
hard

Fix 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'
A3.14
B3,14
C"3.14"
Dpi
Attempts:
3 left
💡 Hint
Common Mistakes
Using commas instead of dots for decimals.
Putting numbers in quotes makes them strings.
4fill in blank
hard

Fill 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'
A5
BTrue
CFalse
D"5"
Attempts:
3 left
💡 Hint
Common Mistakes
Using quotes around True or False makes them strings.
Assigning a string instead of an integer first.
5fill in blank
hard

Fill 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'
A"7.5"
B7.5
C7
D7.0
Attempts:
3 left
💡 Hint
Common Mistakes
Keeping quotes when changing to float or integer.
Using 7.0 instead of 7 for the integer value.