Recall & Review
beginner
What are the three ways to create a string in Python?
You can create strings using single quotes ('example'), double quotes ("example"), or triple quotes ('''example''' or """example"""). Triple quotes allow multi-line strings.
Click to reveal answer
intermediate
How does Python represent strings internally?
Python stores strings as sequences of Unicode characters, allowing support for many languages and symbols beyond ASCII.
Click to reveal answer
intermediate
What is the difference between raw strings and normal strings in Python?
Raw strings (prefix r or R) treat backslashes (\) as literal characters and do not interpret escape sequences like \n or \t.
Click to reveal answer
beginner
How can you include quotes inside a string without ending it?
You can use different quotes to surround the string than the ones inside it, for example: "He said 'hello'" or 'She said "hi"'. Alternatively, use escape characters like \" or \'.
Click to reveal answer
intermediate
What does the repr() function do with strings?
repr() returns a string representation that shows the string with quotes and escape characters, useful for debugging.
Click to reveal answer
Which of these is a valid way to create a multi-line string in Python?
✗ Incorrect
Triple quotes allow strings to span multiple lines.
What does the prefix r before a string mean in Python?
✗ Incorrect
Raw strings do not process escape sequences like \n.
How can you include a double quote inside a string defined with double quotes?
✗ Incorrect
Escape characters allow including quotes inside strings.
What will repr('Hello\nWorld') return?
✗ Incorrect
repr() shows the string with escape characters visible.
Which statement about Python strings is true?
✗ Incorrect
Python strings support Unicode and are immutable.
Explain how to create strings in Python and how to include quotes inside them.
Think about how you can mix quotes or use backslashes.
You got /5 concepts.
Describe the difference between normal strings and raw strings in Python.
Consider how \n behaves in each.
You got /4 concepts.