Explanation:
๐น 1. Calling the print() Function
print(10 == 10.0)
✅ Explanation
print() is used to display the result on the screen.
Before printing anything, Python first evaluates the expression:
10 == 10.0
Only after finding the result does print() display it.
Execution order:
10 == 10.0
↓
Result (True/False)
↓
print()
↓
Output
๐น 2. Understanding the Left Operand
10
✅ Explanation
10 is an integer (int).
Its type is:
type(10)
Output:
<class 'int'>
Memory:
10
↓
Integer (int)
๐น 3. Understanding the Right Operand
10.0
✅ Explanation
10.0 is a floating-point number (float).
Its type is:
type(10.0)
Output:
<class 'float'>
Memory:
10.0
↓
Float
๐น 4. Understanding the == Operator
10 == 10.0
✅ Explanation
The == operator checks whether the values are equal, not whether their data types are the same.
Rule:
==
↓
Compare Values
Not Data Types
Python compares:
10
and
10.0
Numerically, both represent the same value.
๐น 5. Python Performs Type Conversion
✅ Explanation
Before comparing, Python automatically converts the integer to a float.
Internally, it behaves like:
10.0 == 10.0
Now both values are floats.
Comparison:
10.0 == 10.0
↓
True
This automatic conversion is called Implicit Type Conversion (Type Coercion).
๐น 6. Printing the Result
print(True)
✅ Explanation
Since the comparison returned True, print() displays:
True
๐ฏ Final Output
True

0 Comments:
Post a Comment