Bird
Raised Fist0

What will be the output of this code?

medium📝 Predict Output Q5 of Q15
Python - File Reading and Writing Strategies
What will be the output of this code?
text = """Hello
World
Python"""
print(text)
AHello World Python
BHello World Python
CHello\nWorld\nPython
DHelloWorldPython
Step-by-Step Solution
Solution:
  1. Step 1: Understand triple-quoted strings

    Triple quotes preserve line breaks inside the string.
  2. Step 2: Predict print output

    Print will show each word on its own line as in the string.
  3. Final Answer:

    Hello World Python -> Option B
  4. Quick Check:

    Triple quotes preserve new lines [OK]
Quick Trick: Triple quotes keep line breaks in strings [OK]
Common Mistakes:
MISTAKES
  • Expecting all text on one line
  • Printing escaped \n instead of new lines
  • Removing spaces between words

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Python Quizzes