ProgrammingHardTCS CodeVita · Infosys HackWithInfy

What is printed?

What is printed?
print('{0}{1}{0}'.format('a', 'b'), '{:>3}'.format(7), '%%%d' % 5)
  1. A. abab 7 %5
  2. B. aba 7 %5
  3. C. aba 7 %4
  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

Exams that ask this topic