0
0
DSA Pythonprogramming~20 mins

How Strings Work Differently Across Languages in DSA Python - Debugging & Practice

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
String Immutability in Python
What is the output of this Python code snippet?
DSA Python
s = "hello"
s[0] = 'H'
print(s)
ASyntaxError
Bhello
CHello
DTypeError
Attempts:
2 left
πŸ’‘ Hint
Strings in Python cannot be changed after creation.
❓ Predict Output
intermediate
2:00remaining
String Concatenation Performance
What is the output of this Python code?
DSA Python
result = ''
for i in range(3):
    result += str(i)
print(result)
A['0', '1', '2']
B0 1 2
C012
DError
Attempts:
2 left
πŸ’‘ Hint
The loop appends string versions of numbers to result.
❓ Predict Output
advanced
2:00remaining
String Interning Behavior
What is the output of this Python code snippet?
DSA Python
a = 'hello'
b = 'hello'
print(a is b)
ATrue
BFalse
CError
DNone
Attempts:
2 left
πŸ’‘ Hint
Python may reuse the same string object for identical literals.
❓ Predict Output
advanced
2:00remaining
Unicode String Length
What is the output of this Python code?
DSA Python
s = 'naΓ―ve'
print(len(s))
A5
B6
C4
DError
Attempts:
2 left
πŸ’‘ Hint
Python 3 strings are Unicode and count characters, not bytes.
❓ Predict Output
expert
2:00remaining
Mutable vs Immutable String-like Types
What is the output of this Python code?
DSA Python
from array import array
s = 'abc'
a = array('u', s)
a[0] = 'z'
print(''.join(a))
AValueError
Bzbc
Cabc
DTypeError
Attempts:
2 left
πŸ’‘ Hint
array of type 'u' supports mutable Unicode characters.