Bird
0
0

What will be the output of the following code?

medium📝 Predict Output Q13 of 15
Python - Basics and Execution Environment
What will be the output of the following code?
print('Hello')  # This prints Hello
# print('World')
AHello
BSyntaxError
CWorld
DHello\nWorld
Step-by-Step Solution
Solution:
  1. Step 1: Understand the effect of comments on code execution

    The first line prints 'Hello' because the comment after it does not affect the print statement.
  2. Step 2: Recognize that the second print is commented out

    The second print statement is fully commented out, so it does not run or print anything.
  3. Final Answer:

    Hello -> Option A
  4. Quick Check:

    Commented code does not run = Hello [OK]
Quick Trick: Code after # is ignored; only uncommented lines run [OK]
Common Mistakes:
MISTAKES
  • Thinking commented print runs
  • Expecting both Hello and World printed
  • Confusing comment with string

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Python Quizzes