ProgrammingModerateTCS NQT · Wipro pattern
What is printed?
What is printed?
print(len(set('aabbcc')), sorted(set('cba')), 'abc'.index('b') + 'abc'.count('b'))- A. 2 ['a', 'b', 'c'] 2
- B. 3 ['c', 'b', 'a'] 2
- C. 3 ['a', 'b', 'c'] 1
- D. 3 ['a', 'b', 'c'] 2
Correct answer: D. 3 ['a', 'b', 'c'] 2
The set of letters in aabbcc has three members, and sorted gives a, b and c. index('b') is 1 and count('b') is 1, giving 2.
More Python Programming questions
- What is printed? python print(1000000 1000000 == 1012, 0.1 0.1 100 == 1, round(0.1 0.1 100, 10) == 1.0, 2 0.5 == 2 (1 / 2))
- What is printed? python print(sum(range(0, 101, 5)), len(range(0, 101, 5)))
- What is printed? python print(bin(37)[2:].zfill(8), int('100101', 2) == 37)
- What is printed? python import heapq h = [] for x in [5, 2, 8]: heapq.heappush(h, x) print(heapq.heappop(h), heapq.heappop(h), h)
- What is printed? python print(sorted([3, 1, 2], key=lambda x: -x)[0], max([3, 1, 2], key=lambda x: -x))
- What is printed? python print([x for x in range(20) if x % 3 == 0 and x % 4 == 0])