ProgrammingVery hardTCS CodeVita · Infosys HackWithInfy
What is printed?
What is printed?
def fact(n):
return 1 if n <= 1 else n * fact(n - 1)
print(len(str(fact(25))), fact(25) % 10 ** 6 == 0, fact(25) % 7)- A. 26 True 0
- B. 26 False 0
- C. 25 True 0
- D. 26 True 1
Correct answer: A. 26 True 0
25! has 26 digits. It has six trailing zeros, so it is divisible by 10**6. It contains the factor 7, so its remainder modulo 7 is 0.
More Python Programming questions
- What is printed? python x = 'aXbX' print(x.split('X'), x.partition('X')[0] + x.rpartition('X')[2])
- What is printed? python print(2 200 % 7 == pow(2, 200, 7), len(str(2 200)), 2 200 % 7)
- What is printed? python s = 'abc' t = s 2 print(t[::2], t[1::3], t.find('ca'), t.count('b'))
- What is printed? python d = {'a': 1} keys = d.keys() d['b'] = 2 del d['a'] print(list(keys), len(keys))
- What is printed? python print(1 < 2 < 3 > 2 == 2, 1 < 3 < 2, (1 < 3) < 2)
- What is printed? python class Box: def init(self, n): self.n = n def len(self): return self.n def bool(self): return True…