ProgrammingHardProduct-company MCQ pattern
What is printed?
What is printed?
print(abs(-7) // 2 * -1, -abs(-7) // 2, -(abs(-7) // 2))
- A. -3 -4 -4
- B. -4 -4 -3
- C. -3 -4 -3
- D. -3 -3 -3
Correct answer: C. -3 -4 -3
abs(-7) // 2 is 3, and multiplying by -1 gives -3. -abs(-7) is -7, and floor division by 2 gives -4, which differs from negating 3.
More Python Programming questions
- What is printed? python x = 255 print(f'{x:08b}', f'{x:o}', f'{x:X}', f'{x:#010x}')
- What is printed? python print(int('11', 2) + int('11', 8) + int('11', 16))
- What is printed? python print(round(1234.5678, -2), round(-1234.5678, 2), round(0.000123456, 5))
- What is printed? python print(7 / 7, 0 / 5, -0 / 5, 2 0, 0 0.0)
- What is printed? python print(7 // 1.0 1, 1e3 // 7, -1e3 // 7, 10 % -3.0)
- What is printed? python print(bool(''), bool('False'), bool([]), bool([[]]), bool(None))