0
0
Pythonprogramming~20 mins

String creation and representation in Python - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
๐ŸŽ–๏ธ
String Mastery Badge
Get all challenges correct to earn this badge!
Test your skills under time pressure!
โ“ Predict Output
intermediate
2:00remaining
Output of multiline string with escape sequences
What is the output of this Python code?
Python
text = '''Line1\nLine2\tTabbed'''
print(text)
ALine1\nLine2\tTabbed
B
Line1
Line2	Tabbed
CLine1\nLine2 Tabbed
D
Line1
Line2\tTabbed
Attempts:
2 left
๐Ÿ’ก Hint
Triple quotes preserve the string exactly as typed, including backslashes.
โ“ Predict Output
intermediate
2:00remaining
Output of raw string with backslashes
What will this code print?
Python
path = r"C:\new_folder\test"
print(path)
AC:\\new_folder\\test
B
C:
ew_folder	est
CC:new_foldertest
DC:\new_folder\test
Attempts:
2 left
๐Ÿ’ก Hint
Raw strings treat backslashes as normal characters.
โ“ Predict Output
advanced
2:00remaining
Output of string concatenation with different quote styles
What is the output of this code?
Python
s = 'Hello' + " World" + '''!'''
print(s)
AHello World!
BHelloWorld!
CHello World
DHello' World'''
Attempts:
2 left
๐Ÿ’ก Hint
Strings with different quotes can be concatenated normally.
โ“ Predict Output
advanced
2:00remaining
Output of string with Unicode escape sequences
What does this code print?
Python
s = "\u0048\u0065llo"
print(s)
A\u0048\u0065llo
BH\u0065llo
CHello
DHe\u006c\u006c\u006f
Attempts:
2 left
๐Ÿ’ก Hint
Unicode escape sequences represent characters by their code points.
๐Ÿง  Conceptual
expert
3:00remaining
Number of characters in a string with combining Unicode characters
How many characters does this string have? s = "e\u0301" # letter e + combining acute accent
A1
B2
C0
D3
Attempts:
2 left
๐Ÿ’ก Hint
Combining characters count as separate code points in Python strings.