Bird
0
0

What will this code print?

medium📝 Predict Output Q5 of 15
Python - Variables and Dynamic Typing
What will this code print?
value = '123'
value = int(value)
print(type(value))
A<class 'str'>
B<class 'int'>
C<class 'float'>
DError
Step-by-Step Solution
Solution:
  1. Step 1: Analyze variable transformations

    value starts as string '123', then converted to int using int().
  2. Step 2: Check type after conversion

    After int(), value is integer type, so type(value) is int.
  3. Final Answer:

    <class 'int'> -> Option B
  4. Quick Check:

    int() converts string to int type [OK]
Quick Trick: int() converts strings to integers [OK]
Common Mistakes:
MISTAKES
  • Thinking type remains string after int()
  • Expecting float type
  • Confusing int() with str()

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Python Quizzes