ProgrammingHardTCS CodeVita · Infosys HackWithInfy
What is printed?
What is printed?
from functools import reduce import math print(reduce(math.gcd, [12, 18, 24]), reduce(math.lcm, [4, 6, 10]))
- A. 6 120
- B. 2 60
- C. 12 60
- D. 6 60
Correct answer: D. 6 60
gcd(12, 18) = 6 and gcd(6, 24) = 6. lcm(4, 6) = 12, and lcm(12, 10) = 60.
More Python Programming questions
- What is printed? python people = [('ann', 25), ('bob', 30), ('cy', 25), ('dan', 30)] people.sort(key=lambda p: p[0])…
- What is printed? python print(-5 // 2 2 + -5 % 2 == -5, 5 // -2 -2 + 5 % -2 == 5)
- 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)