ProgrammingHardTCS NQT · Infosys
What is printed?
What is printed?
print(int('0b11', 0) + int('0o11', 0) + int('0x11', 0), int('11', 16), int('-0b11', 0))- A. 29 16 3
- B. 28 17 -3
- C. 27 17 -3
- D. 29 17 -3
Correct answer: D. 29 17 -3
The three prefixed literals are 3, 9 and 17, which sum to 29. int('11', 16) is 17, and the sign is kept when the base prefix is read with base 0.
More Python Programming questions
- What is printed? python from math import inf print(inf - 1 == inf, 2 inf, -inf < -10 400, inf > 10 400)
- What is printed? python print(sum(1 for c in 'a1 b2' if c.isalpha()), sum(1 for c in 'a1 b2' if c.isdigit()), sum(c.isspace() for c in 'a1…
- What is printed? python print(round(2.675, 2), round(2.665, 2), round(1.0049999999999999, 3), round(-2.5, 0))
- What is printed? python print(max('apple', 'banana', key=len), max(['x', 'yy', 'zz'], key=len), min([3, 1, 1.0], key=abs), max([1, 1.0]…
- What is printed? python print(float('0.1') + float('0.2') == 0.3, float('0.30000000000000004') == 0.1 + 0.2…
- What is printed? python s = 'hello' print(s.index('l'), s.rindex('l'), s.find('z'), s.count('l'))