Bird
0
0

What will be the output if you run this code in interactive mode line by line?

medium📝 Predict Output Q13 of 15
Python - Basics and Execution Environment
What will be the output if you run this code in interactive mode line by line?
print('Hello')
2 + 3
print('Done')
AHello\nDone
BHello\n3\nDone
CHello\nNone\nDone
DHello\n5\nDone
Step-by-Step Solution
Solution:
  1. Step 1: Analyze print statements in interactive mode

    print('Hello') outputs Hello immediately. print('Done') outputs Done immediately.
  2. Step 2: Understand expression evaluation in interactive mode

    Typing 2 + 3 alone in interactive mode shows 5 as output.
  3. Final Answer:

    Hello\n5\nDone -> Option D
  4. Quick Check:

    Only print outputs show in script; interactive shows expression results [OK]
Quick Trick: Only print() shows output in script; expressions show in interactive [OK]
Common Mistakes:
MISTAKES
  • Expecting expression results printed in script mode
  • Confusing expression output with print output
  • Thinking 2 + 3 prints 5 without print()

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Python Quizzes