ProgrammingHardTCS NQT · Wipro pattern
What is printed?
What is printed?
print('%5s|%-5s|' % ('ab', 'cd'))- A. ab|dc |
- B. ba|cd |
- C. ab|cd |
- D. ab|ce |
Correct answer: C. ab|cd |
%5s right-aligns ab in five columns, and %-5s left-aligns cd in five columns, padding on the right. Both fields are padded to exactly five characters.
More Python Programming questions
- What is printed? python print(len('%-8.3f|' % 3.14159), len('%08.3f' % -3.14159), '%08.3f' % -3.14159)
- What is printed? python import math print(math.prod([]), math.prod(range(1, 6)), math.lcm(range(1, 6)), math.lcm())
- What is printed? python print(list('ab') + ['c'] 2, 'ab' + 'c' 2, ('a',) 2)
- What is printed? python print(10 18 // 7 7 + 10 18 % 7 == 10 18, (-10 18) // 7 7 + (-10 18) % 7 == -10 18, -10 18 % 7 == (-10) 18 % 7)
- What is printed? python from bisect import bisectleft, bisectright a = [1, 2, 2, 2, 3] print(bisectleft(a, 2), bisectright(a, 2)…
- What is printed? python print(str(12345)[::-1], int(str(12345)[::-1]) + 1, sum(int(d) for d in str(12345)), len(str(0)))