ProgrammingModerateTCS NQT · Infosys
What is printed?
What is printed?
print(int('0b101', 0), int('0o17', 8), int('z', 36), int('-0'), int('+7'))- A. 5 16 35 0 7
- B. 5 15 35 1 7
- C. 6 15 35 0 7
- D. 5 15 35 0 7
Correct answer: D. 5 15 35 0 7
Base 0 chooses the base from the prefix, so 0b101 is 5. Base 36 uses letters for digits up to z, which is 35. A leading sign is allowed, so '+7' is 7 and '-0' is 0.
More Python Programming questions
- What is printed? python print(str(True) + str(1 == 1.0), True + True, '3' True, [0] True)
- 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] =…