ProgrammingModerateTCS NQT · Infosys
What is printed?
What is printed?
print('Mississippi'.lower().count('s'), 'Mississippi'.find('ss'), 'Mississippi'.rfind('ss'))- A. 4 2 5
- B. 4 2 2
- C. 3 2 5
- D. 4 3 5
Correct answer: A. 4 2 5
Lowercasing gives four s letters. find returns the first 'ss' at index 2, and rfind returns the last one, at index 5.
More Python Programming questions
- What is printed? python print(float('-0') == 0.0, str(float('-0')), str(float('+0')))
- What is printed? python print(sum(1 for i in range(1, 1001) if '7' in str(i)))
- What is printed? python print(int(str(12345)[::-1]) - 12345, 12345 - int(str(12345)[::-1]))
- What is printed? python print(len(bin(-1)), len(hex(255)), oct(64))
- What is printed? python print(int('12abc', 16), int('ABC', 16) == 0xabc, int('1000000') == 106)
- What is printed? python print('%s' % None, '%r' % None, '%d' % True)