0
0
Pythonprogramming~20 mins

Escape characters in output in Python - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Escape Character Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
Predict Output
intermediate
2: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")
A
Hello
World
BHello\nWorld
CHello World
DHello\World
Attempts:
2 left
💡 Hint
Remember that \n is the escape sequence for a new line.
Predict Output
intermediate
2:00remaining
What does this print with tab escape character?
What is the output of this code snippet?
Python
print("Name:\tJohn")
AName: John
BName:\tJohn
CName:John
DName: John
Attempts:
2 left
💡 Hint
The \t escape character adds a horizontal tab space.
Predict Output
advanced
2:00remaining
What is the output of this string with mixed escape characters?
What will this code print?
Python
print("Line1\nLine2\tTabbed\nLine3\\Backslash")
A
Line1
Line2	Tabbed
Line3\Backslash
B
hsalskcaB\3eniL
debbaT	2eniL
1eniL
C
Line1
Line2	Tabbed
Line3Backslash
DLine1 Line2 Tabbed Line3 Backslash
Attempts:
2 left
💡 Hint
Remember \n is new line, \t is tab, and \\ is a single backslash.
Predict Output
advanced
2:00remaining
What error or output does this code produce?
What happens when you run this code?
Python
print('It\'s a sunny day')
ASyntaxError
BIt\'s a sunny day
CIt's a sunny day
DIt's a sunny day\n
Attempts:
2 left
💡 Hint
The backslash escapes the single quote inside single quotes.
Predict Output
expert
2:00remaining
What is the output of this raw string with escape sequences?
What will this code print?
Python
print(r"C:\\Users\\Admin")
AC:\Users\Admin
BC:\\Users\\Admin
CC:\Users\Admin\
DC:UsersAdmin
Attempts:
2 left
💡 Hint
Raw strings treat backslashes as literal characters.