ProgrammingHardTCS CodeVita · Infosys HackWithInfy
What is printed?
What is printed?
print(f"{1234567.891:,.2f}", f"{255:b}", f"{-5:+d}")- A. 1234567.89 11111111 -5
- B. 1,234,567.9 11111111 -5
- C. 1,234,567.89 255 -5
- D. 1,234,567.89 11111111 -5
Correct answer: D. 1,234,567.89 11111111 -5
The comma option groups thousands and .2f rounds to two decimals. b formats in binary. A + sign applies only to nonnegative numbers, and -5 keeps its minus sign.
More Python Programming questions
- What is printed? python print('-'.join(map(str, [1, 2])) 2, ('ab' 3).count('ba'))
- What is printed? python print('a,,b,'.split(','), ' a b '.split(' '))
- What is printed? python print('1.2.3.4'.rsplit('.', 1), 'x'.partition('='), 'a=b=c'.partition('='))
- What is printed? python print(chr(ord('a') + 27), ord('Z') - ord('A'), chr(0x1F600) == 'U0001F600', len('U0001F600'))
- Which of the following Python operations on a built-in container is O(1) on average (independent of the container size)?
- Timsort is the algorithm behind Python's sorted(). For an input that is already in ascending order, what is its running time?