Loading

Quipoin Menu

Learn • Practice • Grow

python / Strings Deep Dive
mcq
Direction: Choose the correct option

Q1.

How do you get the length of a string?
A. len(s)
B. length(s)
C. s.len()
D. s.length()
Direction: Choose the correct option

Q2.

What is the output of `'hello'.upper()`?
A. 'hELLO'
B. 'hello'
C. 'Hello'
D. 'HELLO'
Direction: Choose the correct option

Q3.

How do you check if a string starts with a substring?
A. s.startswith(sub)
B. s.startsWith(sub)
C. s.startswith(sub)
D. s.start(sub)
Direction: Choose the correct option

Q4.

What does `s.split()` do?
A. Splits into characters
B. Replaces characters
C. Concatenates strings
D. Splits a string into a list of substrings
Direction: Choose the correct option

Q5.

What is the output of `'abc'.join(['1','2','3'])`?
A. '123'
B. '1,2,3'
C. '1abc2abc3'
D. 'abcabcabc'
Direction: Choose the correct option

Q6.

Which method removes whitespace from both ends?
A. strip()
B. trim()
C. lstrip()
D. rstrip()
Direction: Choose the correct option

Q7.

How do you replace all occurrences of 'a' with 'b'?
A. s.sub('a','b')
B. s.replace('a','b')
C. s.replace('a','b')
D. s.replace('a','b')
Direction: Choose the correct option

Q8.

What is the output of `'hello world'.find('world')`?
A. -1
B. 6
C. 0
D. 5
Direction: Choose the correct option

Q9.

What does `'123'.isdigit()` return?
B. FALSE
C. TRUE
D. Error