ProgrammingHardJEE Advanced · CAT placement
What is printed?
What is printed?
import math
print(math.factorial(20) // 10**6 % 1000, len(str(math.factorial(30))), str(math.factorial(30)).count('0'))- A. 176 33 7
- B. 176 33 9
- C. 176 32 7
- D. 175 33 7
Correct answer: B. 176 33 9
20! is 2432902008176640000, so dropping six digits and taking the last three gives 176. 30! has 33 digits, and counting the zero digits of its string form gives 9, not 7.
More Python Programming questions
- What is printed? python print(float('0.1') == 0.1, float(' 0.1 ') == 0.1, 0.1 == float(str(0.1)), 1e23 == 1023)
- What is printed? python total = 0 for s in ['10', '9', ' x', '+7', '10']: try: total += int(s) except ValueError: total -= 1 print(total)
- What is printed? python print('%d' % 3.9, '%d' % -3.9, '%.0f' % 0.5, '%i' % True)
- What is printed? python s = 'héllo' print(s[1], s.encode('latin-1')[1], len(s.encode('utf-16-le')), s.isascii())
- What is printed? python from decimal import Decimal, getcontext getcontext().prec = 4 print(Decimal(1) / Decimal(3), Decimal('1.10') ==…
- What is printed? python print(sorted([(2, 'b'), (1, 'z'), (2, 'a')], reverse=True))