Skip to content
Worked Examples · Example 3.10
Q.
StatementOutput
print("Hello")Hello
print(10*2.5)25.0
Yanam CbseNCERTSubjective· 2mImportance★★★★★est
40% · 10/25 Questions
🔒 Locked · start free trial →

You're viewing a preview — the full solution, concept, methods & PYQ mapping are locked.

Start your 14-day free trial to unlock the full solution →

The table shows Python's automatic type conversion: string concatenation in the first statement and integer-to-float promotion in the second, producing Hello and 25.0.

Understanding Implicit Type Conversion in Python

Python is a dynamically typed language that performs automatic type conversion (also called implicit type conversion or type coercion) when operations involve compatible types. The two statements in the table demonstrate this behavior in different contexts.

Statement 1: print("Hello")

This is straightforward string output. The print() function accepts any object, converts it to its string representation, and writes it to standard output.

  • Input type: str (string literal "Hello")
  • Operation: Direct output, no conversion needed
  • Output: Hello

No type conversion occurs here because the argument is already a string.

Statement 2: print(10*2.5)

This statement involves arithmetic between an integer and a float, which triggers Python's implicit type promotion rules.

Why this conversion happens:

When Python encounters an operation between different numeric types, it follows a hierarchy to prevent data loss:

int→float→complex\text{int} \rightarrow \text{float} \rightarrow \text{complex}

The narrower type is promoted to the wider type. Here:

  • 10 is an int
  • 2.5 is a float
  • Python converts 10 to 10.0 (float)
  • The multiplication 10.0 * 2.5 is performed in floating-point arithmetic
  • Result: 25.0 (a float, not 25)

Step-by-step evaluation:

StepExpressionTypeValue
110int10
22.5float2.5
310 → 10.0float10.0
410.0 * 2.5float25.0
5print(25.0)output25.0

Unlock everything free for 14 days

  • Full step-by-step solutions
  • Concept-first explanations
  • Methods, shortcuts & mistakes
  • PYQ mapping + timed mock tests

Full access for 14 days. No credit card required.