ProgrammingHardTCS NQT · Wipro pattern
What is printed?
What is printed?
x = 3.14159
print(f'{x:.2f}|{42:>5}|{0.5:%}')- A. 3.14| 42|50%
- B. 3.1| 42|50.000000%
- C. 3.14| 42|50.000000%
- D. 3.14| 42|5.000000%
Correct answer: C. 3.14| 42|50.000000%
The .2f spec rounds to two decimals, >5 right-aligns in five columns, and the % spec multiplies by 100 with six decimals by default.
More Python Programming questions
- What is printed? python print(0.1 + 0.2 + 0.3 == 0.6, 0.6 == 0.3 2, 0.3 2 == 0.6)
- What is printed? python print(sorted([10, 2, 33], key=str), sorted(['10', '2', '33'], key=int))
- What is printed? python print('%.2f' % 0.125, '%.2f' % 0.375, '%.1f' % 0.05, '%.0f' % 1.5)
- What is printed? python print(-17 % -5, 17 % -5, -17 % 5, -(17 % 5))
- What is printed? python a = 'ab' b = a 3 print(b.count('ab'), b.count('aba'), len(b.split('b')))
- What is printed? python print(0.1 10 == 1.0, 0.1 10, sum([0.1] 10) == 1)