ProgrammingModerateTCS NQT · Infosys

What is printed?

What is printed?
import math
print(math.gcd(-12, 18), math.gcd(12, -18), math.lcm(-4, 6), math.gcd(0, 0))
  1. A. 6 6 12 1
  2. B. 6 6 12 0
  3. C. 6 6 6 0
  4. D. 6 6 24 0

Correct answer: B. 6 6 12 0

gcd always returns a non-negative value, so the signs of the inputs do not matter. lcm(-4, 6) is 12, and gcd(0, 0) is defined as 0.

More Python Programming questions

Exams that ask this topic