ProgrammingHardTCS CodeVita · Infosys HackWithInfy
What is printed?
What is printed?
print('{0}{1}{0}'.format('a', 'b'), '{:>3}'.format(7), '%%%d' % 5)- A. abab 7 %5
- B. aba 7 %5
- C. aba 7 %4
- D. aba 7 %6
Correct answer: B. aba 7 %5
Indexes 0, 1 and 0 give 'aba'. '{:>3}' right-aligns 7 in three columns. '%%' prints a literal percent sign, followed by 5.
More Python Programming questions
- What is printed? python print(bin(5 << 2), 5 >> 1, -5 >> 1, -5 // 2)
- What is printed? python print(1 if 0 else 2 if 3 else 4, 0 or '' or 'z', 0 and 'z')
- What is printed? python a = [1, 2, 3] b = a 2 b[0] = 9 print(a, b)
- What is printed? python s = 'xxxy' print(s.rstrip('y'), s.strip('x'), repr(s.lstrip('xy')))
- What is printed? python print('abc' < 'abcd', 'Z' < 'a', '10' < '9')
- What is printed? python i = 0 while (i := i + 1) < 4: pass print(i)