Bird
0
0

What is the output of the following code?

medium📝 Predict Output Q4 of 15
Python - Data Types as Values

What is the output of the following code?

a = 5
b = 2
print(a // b)
print(type(a // b))
A2 <class 'float'>
B2.5 <class 'float'>
C2 <class 'int'>
D2.5 <class 'int'>
Step-by-Step Solution
Solution:
  1. Step 1: Understand floor division operator

    The '//' operator performs floor division, returning the largest integer less than or equal to the division result.
  2. Step 2: Calculate and check type

    5 // 2 equals 2 (floor of 2.5). The result is an integer type.
  3. Final Answer:

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

    Floor division result = 2 int [OK]
Quick Trick: Floor division '//' returns int for int inputs [OK]
Common Mistakes:
MISTAKES
  • Confusing '//' with '/'
  • Expecting float from floor division
  • Misreading output type

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Python Quizzes