Bird
0
0

Which of the following is the correct way to print a double quote inside a double-quoted string in Python?

easy📝 Syntax Q3 of 15
Python - Input and Output
Which of the following is the correct way to print a double quote inside a double-quoted string in Python?
Aprint('He said, "Hello"')
Bprint('He said, \'Hello\'')
Cprint("He said, "Hello"")
Dprint("He said, \"Hello\"")
Step-by-Step Solution
Solution:
  1. Step 1: Understand the problem with double quotes

    When a string is enclosed in double quotes, double quotes inside must be escaped to avoid ending the string early.
  2. Step 2: Use the correct escape sequence

    Using \" inside double quotes escapes the double quote character properly.
  3. Final Answer:

    print("He said, \"Hello\"") -> Option D
  4. Quick Check:

    Escape double quote inside double quotes = \" [OK]
Quick Trick: Escape double quotes inside double quotes with \" [OK]
Common Mistakes:
MISTAKES
  • Not escaping double quotes inside double quotes
  • Using single quotes incorrectly
  • Syntax errors from unescaped quotes

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Python Quizzes