Home
MCQs by exam
Python Interview Strings
Python Interview Strings MCQs
27 multiple choice questions typical of the Python Interview Strings exam, with answers and explanations. Switch on practice mode to test yourself first.
print('STRASSE'.casefold() == 'strasse')
A
False
B
None
C
True
Correct answer
D
Error
A
Encrypting strings
B
Splitting strings
C
Compressing strings
D
Reusing a single copy of identical strings in memory
Correct answer
print('abc'[::2])
A
abc
B
ac
Correct answer
C
bc
D
Error
print('xxhello'.lstrip('x'))
A
hello
Correct answer
B
helo
C
olleh
D
Error
print('Programming'[::-1])
A
gnimmargorP
Correct answer
B
Programming
C
Prog
D
Error
print('abc'.isalpha())
A
True
Correct answer
B
False
C
None
D
Error
print(sum(c in 'aeiou' for c in 'education'))
A
2
B
4
C
Error
D
5
Correct answer
A
To save disk space
B
Because of the GIL
C
Operations return new strings, making them hashable and safe to share
Correct answer
D
To prevent slicing
print('ab'.removesuffix('b'))
A
ab
B
b
C
Error
D
a
Correct answer
A
The character for a number
B
The Unicode code point of a character
Correct answer
C
The length of a string
D
The index of a character
print('ab' * 2)
A
ab
B
a b
C
Error
D
abab
Correct answer
print('42'.zfill(5))
A
00042
Correct answer
B
42
C
0042
D
Error
print(f'{3.14159:.2f}')
A
3.1416
B
3
C
3.140
D
3.14
Correct answer
A
2.7
B
3.0
C
3.9
D
3.6
Correct answer
A
lines()
B
split_lines()
C
splitlines()
Correct answer
D
newlines()
s = 'hello'
s[0] = 'H'
A
Error
Correct answer
B
hello
C
h
D
None
print('Python'[::-1])
A
Python
B
P
C
nohtyP
Correct answer
D
n
print('th' in 'Python')
A
False
B
Error
C
True
Correct answer
D
None
try:
'python'.index('z')
except Exception as e:
print(type(e).__name__)
A
-1
B
ValueError
Correct answer
C
None
D
0
print('Python'.startswith('Py'))
A
False
B
None
C
True
Correct answer
D
Error
print('Python'.replace('P', 'J'))
A
Python
B
Jython is
C
Jython
Correct answer
D
Error
print('python'.find('z'))
A
-1
Correct answer
B
0
C
None
D
Error
print('Python'[1:4])
A
yth
Correct answer
B
Pyt
C
ytho
D
tho
print('Python'[-1])
A
P
B
o
C
Error
D
n
Correct answer
A
Removes all spaces
B
Splits a string
C
Converts to lowercase
D
Removes leading and trailing whitespace
Correct answer
Practise on paper
Preparing for Python Interview Strings?
Make it your exam plan: see your progress in every subject and topic, set a daily goal and practise what you have not done yet.
Start my Python Interview Strings plan
Test yourself
Take a timed online test and get a certificate, or play today's quick quiz.
Online tests
Daily quiz