ProgrammingHardTCS CodeVita · Infosys HackWithInfy
What is printed?
What is printed?
from math import comb print(comb(5, 2), comb(5, 7), comb(0, 0), comb(3, 1) * comb(3, 1))
- A. 10 0 1 9
- B. 10 0 1 6
- C. 10 Error 1 9
- D. 10 0 0 9
Correct answer: A. 10 0 1 9
comb(n, k) is 0 when k > n, and comb(0, 0) is 1. comb(5, 2) = 10, and the last term is 3 * 3 = 9.
More Python Programming questions
- What is printed? python x = 0 total = 0 for i in range(1, 6): if i % 2: continue x += i if x > 4: break else: total = -1 print(x, total)
- What is printed? python def f(n): if n <= 1: return n return f(n - 1) + f(n - 2) print(f(20), f.defaults)
- What is printed? python s = 'abcabc' print(s.index('c'), s.rindex('a'), s.find('bca', 1), s.count('bc', 1, 4))
- What is printed? python nums = [4, 9, 16] print(list(map(pow, nums, [0.5] 3)), [n 0.5 for n in nums])
- What is printed? python def gen(n): for i in range(n): yield i i g = gen(4) print(sum(g), sum(g), list(gen(0)))
- What is printed? python words = ['apple', 'Bob', 'cat'] print(sorted(words, key=str.casefold)[0], sorted(words)[0], max(words, key=len))