ProgrammingHardProduct-company MCQ pattern
What is printed?
What is printed?
print(-7.5 % 2, 7.5 % -2, -0.0 % 3)
- A. 0.5 -0.5 0.0
- B. 1.5 -0.5 0.0
- C. 0.5 -0.5 3.0
- D. 0.5 -1.5 0.0
Correct answer: A. 0.5 -0.5 0.0
Float % follows floor division, so -7.5 = -4 * 2 + 0.5. A negative divisor gives a remainder with the divisor's sign, so 7.5 % -2 is -0.5.
More Python Programming questions
- What is printed? python words = 'the quick brown the lazy the'.split() counts = {} for w in words: counts[w] = counts.get(w, 0) + 1…
- What is printed? python print('%.3f' % 1.0005, '%.1f' % 0.25, '%.1f' % 0.35, round(0.35, 1))
- What is printed? python from collections import Counter c = Counter('mississippi') print(c.mostcommon(2), sorted(c.items(), key=lambda kv…
- What is printed? python x = 5 y = x if x > 3 else 0 + 1 if x else -1 print(y, (lambda a, b=2: a b)(3), (lambda a: sum(a))(1, 2, 3))
- What is printed? python print(sorted([2.0, 2, True, 1.5]))
- What is printed? python print(len({1: 'a', True: 'b', 1.0: 'c'}), list({True: 1, 1: 2}.keys()))