ProgrammingVery hardTCS CodeVita · Infosys HackWithInfy
What is printed?
What is printed?
import math print(math.comb(10, 3) % 7, math.perm(5, 2), math.factorial(5) // math.factorial(3))
- A. 2 20 20
- B. 1 10 20
- C. 1 20 60
- D. 1 20 20
Correct answer: D. 1 20 20
comb(10, 3) = 120, and 120 mod 7 is 1 since 7 * 17 = 119. perm(5, 2) = 20. 5!/3! = 120/6 = 20.
More Python Programming questions
- What is printed? python x = [1, 2, 3] it = iter(x) print(next(it), sum(it), list(it))
- What is printed? python def tri(n): return n (n + 1) // 2 print(tri(10), tri(0), [tri(k) for k in range(4)])
- What is printed? python def f(xs): xs.sort() return xs data = [3, 1, 2] res = f(data) print(data is res, data)
- Which Python construct is the most efficient way to test whether a sorted list a contains x in O(log n) time without building extra…
- Which of the following problems can be solved correctly by a greedy algorithm that sorts by end time, when given the intervals and asked…
- What is printed? python a = [1, 2, 3, 4, 5, 6] print(a[1::2], a[::-2], a[4:1:-1])