PCEP-30-02 · Question #256
Strings in Python are delimited with:
The correct answer is A. double quotes (i.e., ") or single quotes (i.e., '). Python strings are delimited by either double quotes ("hello") or single quotes ('hello'), making A correct - both styles are fully interchangeable, and you can even mix them to avoid escaping (e.g., "it's easy"). Asterisks (`) are multiplication and unpacking operators in…
Question
Options
- Adouble quotes (i.e., ") or single quotes (i.e., ')
- Basterisks (i.e., *)
- Cdollar symbol (i.e., $)
- Dbackslashes (i.e., )
How the community answered
(44 responses)- A77% (34)
- B2% (1)
- C5% (2)
- D16% (7)
Explanation
Python strings are delimited by either double quotes ("hello") or single quotes ('hello'), making A correct - both styles are fully interchangeable, and you can even mix them to avoid escaping (e.g., "it's easy"). Asterisks (*) are multiplication and unpacking operators in Python, not string delimiters. The dollar sign ($) has no special meaning in Python at all - it's used in other languages like Bash and PHP for variables. Backslashes (\) appear inside strings as escape characters (e.g., \n for newline), but they don't wrap or delimit the string itself.
Memory tip: Think of quotes as "quotation marks" - the same symbols you'd use to quote someone in writing. Python just gives you two flavors so you can pick whichever doesn't conflict with your string's content.
Community Discussion
No community discussion yet for this question.