ProgrammingModerateTCS NQT · Infosys
What is printed?
What is printed?
print(int('0o777', 8) == 511, int('777', 8) - int('0o777', 0))- A. True 511
- B. False 0
- C. True 0
- D. True 510
Correct answer: C. True 0
int accepts a 0o prefix when the base matches, and base 0 reads the prefix to choose the base. Both conversions give 511, so their difference is 0.
More Python Programming questions
- What is printed? python print(len('%d' % -0), '%d' % -0.0, '%.1f' % -0.0)
- What is printed? python print(max('abc', 'abd', key=lambda s: s[::-1]), min('ba', 'ab', key=len))
- What is printed? python print(sorted([1, 10, 2], key=lambda x: str(x)[0]))
- What is printed? python print(0.1 + 0.1 == 0.2, 0.1 + 0.1 + 0.1 == 0.3, 0.2 + 0.2 == 0.4)
- What is printed? python print(list(range(2, 20, 5)), list(range(-1, -10, -4)))
- What is printed? python print(len(str(71000)), 71000 % 10)