Bird
0
0

Given the code below, what will be the final type of data?

hard📝 Application Q15 of 15
Python - Variables and Dynamic Typing
Given the code below, what will be the final type of data?
data = 100
if isinstance(data, int):
    data = str(data)
else:
    data = [data]
Aint
Bstr
Clist
Dbool
Step-by-Step Solution
Solution:
  1. Step 1: Check initial type of data

    data starts as 100, which is an int.
  2. Step 2: Evaluate the if condition

    Since data is int, the if block runs, converting data to str('100').
  3. Final Answer:

    str -> Option B
  4. Quick Check:

    int converted to str by condition = B [OK]
Quick Trick: If int, convert to str; else make list. [OK]
Common Mistakes:
MISTAKES
  • Ignoring the if condition and assuming list.
  • Thinking data remains int after reassignment.
  • Confusing str and bool types.

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Python Quizzes