ProgrammingHardProduct-company MCQ pattern
What is printed?
What is printed?
import math print(math.gcd(0, -6), math.lcm(4, 6), -7 % -3, math.lcm(0, 5))
- A. 6 12 -2 0
- B. 6 12 1 5
- C. -6 12 -3 0
- D. 6 12 -1 0
Correct answer: D. 6 12 -1 0
gcd is always non-negative, so gcd(0, -6) is 6. The result of % takes the sign of the divisor, so -7 % -3 is -1, and lcm with 0 is 0.
More Python Programming questions
- What is printed? python x = 6 print(x & (x - 1), x & -x, (x ^ (x >> 1)) & 1, x.bitlength(), (-x).bitlength())
- What is printed? python print(bin(10 ^ 6), 10 ^ 6 ^ 6, 3 ^ 5 ^ 3 ^ 5, ~-1, -~1)
- What is printed? python a = 1 if 3 > 2 else 0 print(a << 3 | 1, a << (3 | 1), 2 + 3 4 2 // 8 % 5)
- What is printed? python print(1 < 2 < 3 != 4, (1 < 2) < 3, 2 -1, 2 0.5 2)
- What is printed? python print(int(1e22) == 1022, int(1e23) == 1023, 1e23 == 1023, float(1023) == 1e23)
- What is printed? python print(0.1 + 0.7, 0.1 7, round(0.1 7 10), 3 0.1 == 0.30000000000000004)