Certified Entry-Level Python Programmer (PCEP-30-02) — Question 47

If you want to build a string that reads:
Peter's sister's name's "Anna"
Which of the following literals would you use? (Choose two.)

Answer options

Correct answer: B, D

Explanation

Option B correctly escapes the single quotes and double quotes, making it a valid string literal in most programming languages. Option D also correctly uses escape characters for the double quotes while keeping the single quotes intact. Options A and C are incorrect because they do not handle the quotes properly, leading to syntax errors.