0
0
Pythonprogramming~20 mins

Dynamic typing in Python - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Dynamic Typing Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
Predict Output
intermediate
1:30remaining
What is the output of this dynamic typing example?
Consider the following Python code that uses dynamic typing. What will be printed?
Python
x = 5
x = 'hello'
print(x)
ATypeError
B5
CNameError
Dhello
Attempts:
2 left
💡 Hint
Remember, Python variables can change type at any time.
Predict Output
intermediate
1:30remaining
What is the output when changing variable types?
What will this code print?
Python
a = 10
b = a
b = 'changed'
print(a)
ATypeError
Bchanged
C10
DNone
Attempts:
2 left
💡 Hint
Changing b does not affect a because integers are immutable.
Predict Output
advanced
2:00remaining
What error does this code raise?
What error will this code produce?
Python
x = 5
x = x + '10'
print(x)
AValueError
BTypeError
CSyntaxError
D5
Attempts:
2 left
💡 Hint
You cannot add an integer and a string directly.
Predict Output
advanced
1:30remaining
What is the output of this variable reassignment?
What will be printed by this code?
Python
var = [1, 2, 3]
var = 'now a string'
print(type(var))
A<class 'str'>
B<class 'list'>
C<class 'int'>
DTypeError
Attempts:
2 left
💡 Hint
The variable var is reassigned to a string.
🧠 Conceptual
expert
2:30remaining
Which option best explains dynamic typing in Python?
Choose the statement that correctly describes dynamic typing in Python.
AVariables do not have types; only values have types, and variables can be reassigned to values of any type.
BVariables are statically typed and checked at compile time.
CPython requires explicit type declarations for all variables.
DVariables have fixed types and cannot change after assignment.
Attempts:
2 left
💡 Hint
Think about whether variables themselves have types or if types belong to values.