ProgrammingVery hardTCS NQT · Accenture
What is printed?
What is printed?
import math print(math.gcd(0, -5), math.gcd(-4, -6), math.lcm(0, 5), math.lcm(-4, 6))
- A. 5 3 0 12
- B. 5 2 0 12
- C. 5 2 5 12
- D. -5 2 0 13
Correct answer: B. 5 2 0 12
gcd ignores signs, and gcd(0, n) is the absolute value of n. The lcm of 0 and any number is 0, and lcm(-4, 6) is 12 because the sign is ignored.
More Python Programming questions
- What is printed? python print(len('%.3f' % 260), '%.3f' % 260, '%.0f' % 1e20)
- What is printed? python print(round(1e16 + 2), round(9.5), round(10.5), round(-9.5))
- What is printed? python print(type(1 / 2).name, type(1 // 2).name, type(2 -1).name, type(2 0.5).name, type(True + 1).name)
- What is printed? python print(sorted(['10', '9', '1.5']), sorted(['10', '9', '1.5'], key=float))
- What is printed? python print(max('the', 'a', key=len), min(['b', 'B'], key=str.lower), ''.join(sorted('cab')), 'cab'.upper().swapcase())
- What is printed? python print(int(str(1020 + 1)[-1]) + len(str(1020)), 1020 + 1 == int(str(1020 + 1)))