Worked Examples · Example 5.16
Q.
Example 5.16:
| Statement | Output |
|---|---|
| print("Hello") | Hello |
| print(10*2.5) | 25.0 |
| print("I" + "love" + "my" + "country") | Ilovemycountry |
| print("I'm", 16, "years old") | I'm 16 years old |
West Bengal WbchseTextbookSubjective· 2mImportance★★★★★est
55% · 27/49 Questions
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 four statements demonstrate how print() handles a plain string, an arithmetic expression, string concatenation with +, and comma-separated mixed-type items.
The idea (Data Type Conversion and print() behaviour). print() first evaluates whatever is inside the parentheses, converts each resulting value to its text form, and then displays it. How the values get joined depends on whether you used + (an operator applied before printing) or , (a separator applied by print() itself).
Let us verify each row of the table:
print("Hello")
print(10*2.5)
print("I" + "love" + "my" + "country")
print("I'm", 16, "years old")
Hello
25.0
Ilovemycountry
I'm 16 years old
Row-by-row reasoning
print("Hello")— a string literal is displayed as its contents; the enclosing quotes are part of the syntax, not the value, so the output isHello(no quotes).print(10*2.5)— the expression10*2.5is evaluated first. Multiplying anintby afloatmakes Python implicitly convert theinttofloat, so the result is the float25.0, and that is exactly what is printed — not25.print("I" + "love" + "my" + "country")— for strings,+means concatenation. It glues the pieces together exactly as given, adding nothing in between, so the output isIlovemycountry(no spaces, because the strings themselves contain none). …
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.