ProgrammingVery hardTCS NQT · Accenture
What is printed?
What is printed?
print(oct(0o17 + 0b11), 0x10 | 0o7, 1_0 + 0x_1)
- A. 0o21 23 11
- B. 0o22 22 11
- C. 0o22 23 10
- D. 0o22 23 11
Correct answer: D. 0o22 23 11
0o17 is 15 and 0b11 is 3, so the sum is 18, which is 0o22 in octal. 0x10 | 0o7 is 16 | 7 = 23, and the literals 1_0 and 0x_1 give 10 + 1.
More Python Programming questions
- What is printed? python print('x'.center(4, '-') + '|', '7'.zfill(3) + '|', '-7'.zfill(4))
- What is printed? python print(max(3, 3.5, 2), min('b', 'a', 'c'), max([1, 2], [1, 3]))
- What is printed? python print(len(str(9 20)), str(9 20)[0], sum(map(int, str(9 20))) % 9)
- What is printed? python from fractions import Fraction print(Fraction('1.5'), Fraction('3/6'), float(Fraction('1/3')) == 1/3…
- What is printed? python print(sum([[1, 2], [3]], []), ''.join(['ab', 'c']), [x for x in 'hey'][::2])
- What is printed? python print('%o' % 8 == oct(8)[2:], '%x' % 255 == hex(255)[2:], bin(5)[2:].zfill(4))