ProgrammingHardTCS NQT · Infosys
What is printed?
What is printed?
print(f'{2**70:,}'[:8], len(f'{2**70:,}'), str(2**70)[-3:], ('%d' % 2**70)[-3:])- A. 1,180,59 29 423 424
- B. 1,180,591 30 424 424
- C. 1,180,59 28 424 424
- D. 1,180,59 29 424 424
Correct answer: D. 1,180,59 29 424 424
2**70 has 22 digits, so with 7 thousands separators the grouped form has 29 characters. The last three digits are 424, and %d gives the same digits as str.
More Python Programming questions
- What is printed? python data = [('x', 3), ('y', 1), ('z', 3)] print(max(data, key=lambda t: t[1]), min(data, key=lambda t: -t[1]))
- What is printed? python print(0.1 + 0.2 == 0.30000000000000004, 0.1 + 0.2 - 0.30000000000000004 == 0, '%.20f' % (0.1 + 0.2))
- What is printed? python s = '42' print(s 2 + '!' if s.isdigit() else '', int(s) 2, s.zfill(4) + '|' + s.rjust(4, '0') + '|' + s.ljust(4…
- What is printed? python print(sum(map(int, '123456789')) == 45, sum(map(int, str(99))), 99 % 9)
- What is printed? python print('a' 3 < 'b', 'a' 3 < 'aa', 'aaa' > 'aab', 'aa' + 'b' > 'aab')
- What is printed? python x = 5 print(x // 2 2 == x, x / 2 2 == x, 5 / 2 == 2.5, 5 // 2.0 == 2)