ProgrammingHardProduct-company MCQ pattern
What is printed?
What is printed?
print(str(True) + str(1 == 1.0), True + True, '3' * True, [0] * True)
- A. TrueTrue 2 3 [0]
- B. TrueTrue 2 3 [0, 0]
- C. TrueTrue 2 1 [0]
- D. TrueTrue 3 3 [0]
Correct answer: A. TrueTrue 2 3 [0]
bool is a subclass of int, so True + True is 2. Repetition by True uses it as 1, so '3' * True is '3' and [0] * True is [0].
More Python Programming questions
- What is printed? python print(max('apple', 'banana', key=len), max('pear', 'fig', key=len), min('bb', 'aa', 'c', key=len))
- What is printed? python print('ab'.startswith(('x', 'a')), 'abc'.endswith('', 3), 'abc'.index('c', -1), 'aXbX'.split('X', 1))
- What is printed? python print(ord('A') + 1, chr(ord('a') + 25), chr(0x1F600) == 'U0001F600', len('U0001F600'), 'N{SNOWMAN}')
- What is printed? python from functools import cmptokey w = ['bb', 'a', 'ccc', 'ab', 'c'] def c(x, y): if len(x) != len(y): return len(x)…
- What is printed? python from collections import deque g = ["..#", ".#.", "..."] d = [[-1] 3 for in range(3)] q = deque([(0, 0)]) d[0][0] =…
- What is printed? python import bisect a = sorted([5, 1, 9, 3, 7]) print(bisect.bisectright(a, 7) - bisect.bisectleft(a, 4))