ProgrammingModerateTCS NQT · Infosys
What is printed?
What is printed?
print(-5 % 3 == 1, 5 % -3 == -1, -5 // -3, 5 // -3)
- A. True True 2 -2
- B. True True 1 -2
- C. True False 1 -2
- D. True True 1 -1
Correct answer: B. True True 1 -2
-5 % 3 is 1 and 5 % -3 is -1, both with the divisor's sign. -5 // -3 floors 1.67 to 1, while 5 // -3 floors -1.67 to -2.
More Python Programming questions
- What is printed? python s = 'a-bc d' print(s.replace('-', ' ').replace('', ' ').split(), s.translate({45: None}))
- What is printed? python print('abc'.index('c') + 'abc'.rindex('a'), 'aXbXc'.rsplit('X', 1), 'a b'.title())
- What is printed? python import string print(string.asciilowercase.index('z'), string.digits[::-1][:3], string.asciiuppercase[25] +…
- What is printed? python print(int('1' 30) % 97, pow(10, 30, 97), (1030 - 1) // 9 % 97)
- What is printed? python print(sum(int(c) for c in str(21000)), len(str(21000)))
- What is printed? python print(len(set(str(i i) for i in range(10))), sorted([(-1) i i for i in range(6)]))