ProgrammingModerateTCS NQT · Wipro pattern
What is printed?
What is printed?
print('abc'.find(''), 'abc'.count(''), ''.split(), ''.split(','))- A. 1 4 [] ['']
- B. 0 4 [] ['']
- C. -1 4 ['a'] ['']
- D. 0 3 [] []
Correct answer: B. 0 4 [] ['']
The empty string is found at index 0 and occurs four times in a three-character string. split() with no argument returns an empty list for empty text, while split(',') returns one empty string.
More Python Programming questions
- What is printed? python from fractions import Fraction print(Fraction(1, 3) == 1/3, Fraction(1, 3) == Fraction('0.3333333333333333')…
- What is printed? python print('Hello, World'.swapcase(), 'hello world'.title(), "it's here".capitalize(), 'ABC'.isupper())
- What is printed? python print(float('9007199254740993') == 9007199254740993, int(float('9007199254740993')), int(9007199254740993.0))
- What is printed? python print(len('abc' 1000000 + ''), 'abc' in 'x' 10 + 'abc', 'ab' < 'abc', [1, 2] < [1, 2, 0])
- What is printed? python print(10 -1 == 0.1, 10 0.5 == 10 (1 / 2), int(10 0.5) 2 == 10, round(10 0.5 10 0.5, 9))
- What is printed? python from functools import cmptokey print(sorted(['10', '9', '2'], key=cmptokey(lambda a, b: int(a) - int(b))))