ProgrammingHardTCS NQT · Infosys
What is printed?
What is printed?
print('x'.center(4, '-') + '|', '7'.zfill(3) + '|', '-7'.zfill(4))- A. -x--| 007| -007
- B. --x-| 008| -007
- C. -x--| 007| -0007
- D. -x--| 00| -007
Correct answer: A. -x--| 007| -007
center puts the extra padding character on the left when the padding is odd, giving -x--. zfill pads with zeros after any sign, so -7 becomes -007.
More Python Programming questions
- What is printed? python print(max(3, 3.5, 2), min('b', 'a', 'c'), max([1, 2], [1, 3]))
- What is printed? python print(len(str(9 20)), str(9 20)[0], sum(map(int, str(9 20))) % 9)
- What is printed? python from fractions import Fraction print(Fraction('1.5'), Fraction('3/6'), float(Fraction('1/3')) == 1/3…
- What is printed? python print(sum([[1, 2], [3]], []), ''.join(['ab', 'c']), [x for x in 'hey'][::2])
- What is printed? python print('%o' % 8 == oct(8)[2:], '%x' % 255 == hex(255)[2:], bin(5)[2:].zfill(4))
- What is printed? python print(-1 2, (-1) 2, -1 -1, (-1) -1)