Challenge - 5 Problems
Escape Character Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ Predict Output
intermediate2:00remaining
What is the output of this code with escape characters?
Consider the following Python code snippet. What will it print?
Python
print("Hello\nWorld")
Attempts:
2 left
💡 Hint
Remember that \n is the escape sequence for a new line.
✗ Incorrect
The \n escape character creates a new line in the output, so the print statement outputs Hello on one line and World on the next.
❓ Predict Output
intermediate2:00remaining
What does this print with tab escape character?
What is the output of this code snippet?
Python
print("Name:\tJohn")
Attempts:
2 left
💡 Hint
The \t escape character adds a horizontal tab space.
✗ Incorrect
The \t adds a tab space between 'Name:' and 'John', so the output has extra space.
❓ Predict Output
advanced2:00remaining
What is the output of this string with mixed escape characters?
What will this code print?
Python
print("Line1\nLine2\tTabbed\nLine3\\Backslash")
Attempts:
2 left
💡 Hint
Remember \n is new line, \t is tab, and \\ is a single backslash.
✗ Incorrect
The output has three lines: 'Line1', then 'Line2' followed by a tab and 'Tabbed', then 'Line3\Backslash' with a single backslash.
❓ Predict Output
advanced2:00remaining
What error or output does this code produce?
What happens when you run this code?
Python
print('It\'s a sunny day')
Attempts:
2 left
💡 Hint
The backslash escapes the single quote inside single quotes.
✗ Incorrect
The backslash before the single quote allows it to be part of the string, so it prints: It's a sunny day.
❓ Predict Output
expert2:00remaining
What is the output of this raw string with escape sequences?
What will this code print?
Python
print(r"C:\\Users\\Admin")
Attempts:
2 left
💡 Hint
Raw strings treat backslashes as literal characters.
✗ Incorrect
Raw strings (prefixed with 'r') treat backslashes as literal characters, not escape sequences. Thus, r"C:\\Users\\Admin" prints C:\\Users\\Admin.