ProgrammingModerateTCS NQT · Wipro pattern
What is printed?
What is printed?
print(bin(5), oct(8), hex(16), int('101', 2) + int('7', 8))- A. 0b101 0o8 0x16 12
- B. 0b101 0o10 0x10 5
- C. 0b11 0o10 0x10 12
- D. 0b101 0o10 0x10 12
Correct answer: D. 0b101 0o10 0x10 12
bin(5) is 0b101, oct(8) is 0o10 and hex(16) is 0x10. int('101', 2) is 5 and int('7', 8) is 7, so the sum is 12.
More Python Programming questions
- What is printed? python print(sorted(['apple', 'Banana', 'cherry'], key=str.lower), sorted(['apple', 'Banana', 'cherry']))
- What is printed? python print(sum(range(5)) / len(range(5)), sum([1, 2, 3, 4]) // 4, 9 // 2 2 + 9 % 2)
- What is printed? python print(str(3) + str(4) == '34', 3 + 4 == 7, '3' + '4' == 7)
- What is printed? python print(len(''), len(' '), len('t'), ''.isspace())
- What is printed? python print(1 + '1' if False else '1' + str(1), '3' 2 + str(4 - 1), int('3' 2) + 4 - 1)
- What is printed? python print(bool(0 or '' or []), bool([[]]), bool([0]), bool(' '.strip()))