ProgrammingHardProduct-company MCQ pattern
What is printed?
What is printed?
print('ab' in 'cabd', '' in 'abc', 'abc'.index(''), len('abc'[3:]), len('abc'[4:]))- A. True False 0 0 0
- B. True True 1 0 0
- C. True True 0 0 0
- D. True True 0 3 0
Correct answer: C. True True 0 0 0
The empty string is a substring of every string, and index('') is 0. Slicing past the end gives an empty result rather than an error.
More Python Programming questions
- What is printed? python print(sum(map(int, str(220))), len(str(350)), str(105)[::-1].count('0'))
- What is printed? python print(float('0.1') + float('0.2') == float('0.30000000000000004'), 0.1 + 0.2 == 0.30000000000000004)
- What is printed? python print(5 // 0.4, 5 % 0.4, 0.4 12 == 4.8, 5 / 0.4)
- What is the time complexity of s[::-1] for a string of length n in CPython?
- Which call builds one string from n pieces in O(total length) time?
- Which statement about sorting in Python is correct?