ProgrammingVery hardTCS NQT · Accenture
What is printed?
What is printed?
print(10 ** 18 // 7 * 7 + 10 ** 18 % 7 == 10 ** 18, (-10 ** 18) // 7 * 7 + (-10 ** 18) % 7 == -10 ** 18, -10 ** 18 % 7 == (-10) ** 18 % 7)
- A. True True True
- B. True False True
- C. True True False
- D. False True False
Correct answer: C. True True False
The identity a == (a // b) * b + a % b holds for any sign. The unary minus in -10 ** 18 applies after the power, so -10 ** 18 % 7 is 6 while (-10) ** 18 % 7 is 1.
More Python Programming questions
- What is printed? python from bisect import bisectleft, bisectright a = [1, 2, 2, 2, 3] print(bisectleft(a, 2), bisectright(a, 2)…
- What is printed? python print(str(12345)[::-1], int(str(12345)[::-1]) + 1, sum(int(d) for d in str(12345)), len(str(0)))
- What is printed? python print(0o777 ^ 0o070, 0b1111 & 0xF0 | 0x0F, 1000000 // 1e3)
- What is printed? python s = 'Straße' print(s.upper(), s.lower(), s.casefold() == 'strasse', len(s.upper()))
- What is printed? python print(0.1 0.1 == 0.01, 0.1 0.1, round(0.1 0.1, 2) == 0.01)
- What is printed? python print(int(3.99999999999999999), int(-3.7), 3.99999999999999999 == 4.0, 3)