ProgrammingHardTCS CodeVita · Infosys HackWithInfy
What is printed?
What is printed?
print(-5 // 2 * 2 + -5 % 2 == -5, 5 // -2 * -2 + 5 % -2 == 5)
- A. True False
- B. False False
- C. True True
- D. False True
Correct answer: C. True True
Python keeps the identity (a // b) * b + a % b == a for both signs, so each side equals the original number. The checks are True.
More Python Programming questions
- What is printed? python a = [1, 2, 3] a.append(a) print(len(a), a[-1][-1][0])
- What is printed? python x = 'a,b;c d' print(x.replace(',', ' ').replace(';', ' ').split(), x.replace(',', ' ').split(' '))
- What is printed? python import string print(string.asciilowercase.index('z') - string.asciiuppercase.index('A'), len(string.digits +…
- What is printed? python a = [5, 1, 4] b = a a = sorted(a) c = a.copy() c.reverse() print(a, b, c)
- What is printed? python def f(a, b=[]): b.append(a) return len(b) print(f(1), f(2, []), f(3))
- What is printed? python values = [4, 8, 15, 16, 23, 42] print(bisect.bisect(values, 15) if False else 0, [v for v in values if v % 2 and v…