Bird
0
0

What will the following code print?

easy📝 Conceptual Q1 of 15
Python - Input and Output

What will the following code print?
print("Hello, {}!".format("Alice"))

AHello, {}!
BHello, Alice!
CHello, format!
DError
Step-by-Step Solution
Solution:
  1. Step 1: Understand the format() method usage

    The curly braces {} are placeholders replaced by the argument inside format().
  2. Step 2: Replace placeholder with 'Alice'

    The string becomes 'Hello, Alice!'.
  3. Final Answer:

    Hello, Alice! -> Option B
  4. Quick Check:

    format() replaces placeholders = Hello, Alice! [OK]
Quick Trick: Use {} as placeholders and fill with format() arguments [OK]
Common Mistakes:
MISTAKES
  • Forgetting to call format()
  • Using wrong placeholder syntax
  • Expecting format() to change original string

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Python Quizzes