Bird
0
0

What will be the type of the variable after this code?

easy📝 Conceptual Q2 of 15
Python - Variables and Dynamic Typing
What will be the type of the variable after this code?
value = 7.89
converted = int(value)
Afloat
Bint
Cstring
Dbool
Step-by-Step Solution
Solution:
  1. Step 1: Understand int() conversion from float

    The int() function converts a float to an integer by removing the decimal part.
  2. Step 2: Determine the type of converted variable

    After conversion, the variable is an integer type.
  3. Final Answer:

    int -> Option B
  4. Quick Check:

    float to int = int() [OK]
Quick Trick: int() drops decimals when converting from float [OK]
Common Mistakes:
MISTAKES
  • Expecting rounding instead of truncation
  • Assuming type remains float
  • Using str() instead of int()

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Python Quizzes