ProgrammingHardTCS NQT · Infosys
What is printed?
What is printed?
print(2 ** 10 == 1024, 2 ** 10 == 1 << 10, 10 ** 2 ** 3, (10 ** 2) ** 3)
- A. True False 100000000 1000000
- B. True True 1000000 1000000
- C. True True 100000000 1000000
- D. True True 100000000 100000
Correct answer: C. True True 100000000 1000000
** is right-associative, so 10 ** 2 ** 3 is 10 ** 8. Parentheses force (10 ** 2) ** 3, which is 10 ** 6.
More Python Programming questions
- What is printed? python from itertools import accumulate print(list(accumulate([1, 2, 3], lambda a, b: a b)), list(accumulate('ab'…
- What is printed? python print(sorted({'b': 1, 'a': 1}.items()), list({3: 'x', 1: 'y'}), dict(zip('ab', [1, 2])), dict.fromkeys('ab', 0))
- What is printed? python print(len({1, 1.0, True, '1'}), len({'1', 1}), {1, 2} == {2.0, 1.0}, {0} == {False})
- What is printed? python print(float('1' + '0' 308) == 1e308, 10 308 > 1e308, 10 308 < 1e308)
- What is printed? python from functools import reduce print(reduce(lambda acc, ch: acc 10 + int(ch), '2024', 0), reduce(lambda acc, ch: acc…
- What is printed? python print('{0:>{1}}'.format('x', 3), '{:0>3}'.format(7), '{:x<4}'.format('ab'), '{:^7.3f}|'.format(2.5))