ProgrammingHardProduct-company MCQ pattern
What is printed?
What is printed?
print(int(True) + int('0b11', 2), int(3.7 // 1), int(-0.5), round(-0.5), round(0.5))- A. 4 3 0 0 0
- B. 3 3 0 0 0
- C. 4 3 -1 0 0
- D. 4 3 0 -1 0
Correct answer: A. 4 3 0 0 0
int('0b11', 2) accepts the prefix and gives 3, and int(True) is 1. int truncates -0.5 to 0, and round uses half-to-even, so round(-0.5) and round(0.5) are both 0.
More Python Programming questions
- What is printed? python n = 0b10110000 print(n & -n, n & (n - 1), bin(n >> 4), n.bitcount())
- What is printed? python a, b = 5, 9 a ^= b b ^= a a ^= b print(a, b, a ^ b)
- What is printed? python print(0xFF >> 4 << 4 == 0xF0, 1 << 63 > 0, (1 << 63) - 1 == 263 - 1, -(1 << 63) >> 63)
- What is printed on the third line? python names = ['bob', 'Alice', 'carl', 'Bob', 'alice'] print(sorted(names)) print(sorted(names…
- What is printed? python x = 253 print(float(x + 1) == x, x + 1.0 == x, (x + 2.0) - x, int(float(x + 3)) - x)
- What is printed? python print([10, 20, 30][True], (5).bitlength(), (True).bitlength(), (-1).bitlength())