Question Detail

COS 102 Python strings Objective Question

Question

Which of the following string declarations is considered invalid in Python based on the 'Creating Strings' rule?
Options
A <code>name = 'Alice"</code>
Correct Answer
B <code>city = "New York"</code>
C <code>address = '''123 Main St'''</code>
D <code>quote = """'Hello'"""</code>
Correct Answer

Option A is the correct answer.

Detailed Explanation

The 'Creating Strings' section (page 4) states, 'Note: Quotes must match at the beginning and end!' Option A starts with a single quote (') but ends with a double quote ("), which is invalid.

Hint

Carefully check the opening and closing quotes for each option.

Question Info