Recall & Review
beginner
What is an escape character in Python?
An escape character is a backslash (\) used before a character to give it a special meaning, like \n for a new line or \t for a tab.
Click to reveal answer
beginner
What does the escape sequence \n do in a Python string?
It creates a new line in the output, moving the text after it to the next line.
Click to reveal answer
beginner
How do you print a double quote (") inside a string in Python?
Use the escape character before the double quote like this: \" inside the string.
Click to reveal answer
beginner
What is the output of this code? <br>
print("Hello\tWorld")Hello World<br>The \t adds a tab space between Hello and World.
Click to reveal answer
beginner
Why do we need escape characters in strings?
Because some characters like quotes or new lines have special meanings, escape characters let us include them as normal text or control formatting.Click to reveal answer
Which escape character adds a new line in Python strings?
✗ Incorrect
The escape character \n moves the text to a new line.
How do you include a backslash character in a Python string?
✗ Incorrect
Use \\ to print a single backslash because \ is the escape character.
What will print("She said \"Hi\"") output?
✗ Incorrect
The \" escapes the quotes so they appear in the output.
Which escape character adds a tab space in output?
✗ Incorrect
The \t adds a horizontal tab space.
What does the escape character \r do in Python strings?
✗ Incorrect
The \r moves the cursor to the start of the line, overwriting text.
Explain what escape characters are and why they are useful in Python output.
Think about how to show quotes or new lines inside text.
You got /3 concepts.
Describe how to print a string that includes both double quotes and a new line using escape characters.
Combine \" and \n inside the string.
You got /3 concepts.