ProgrammingHardTCS NQT · Accenture
What is printed?
What is printed?
print('%5.1f|%-5d|' % (3.14159, 42))- A. 3.1|41 |
- B. 3.1| 43|
- C. 3.1|42 |
- D. 3.14|42 |
Correct answer: C. 3.1|42 |
%5.1f gives one decimal in five columns, which pads the 3.1 with two leading spaces. %-5d left-aligns 42 in five columns.
More Python Programming questions
- What is printed? python print(max(range(7), key=lambda i: (i % 3, i)))
- What is printed? python print(5 // 0.5, 5 % 0.5)
- What is printed? python print('xy'.replace('', '-'))
- What does this Python code print? a = [1, 2, 3] b = a a += [4] a = a + [5] print(b, a)
- What does this Python code print? it = iter([1, 2, 3, 4, 5]) print(any(x > 2 for x in it), next(it))
- What does this Python code print? def f(x, acc=[]): acc.append(x) return len(acc) print(f(1), f(2), f(3, []), f(4))