ProgrammingModerateTCS NQT · Infosys

What is printed?

What is printed?
s = '2024-06-01'
y, m, d = map(int, s.split('-'))
print(y + m + d, s.replace('-', '/'), '%02d/%02d/%04d' % (d, m, y))
  1. A. 2031 2024-06-02 01/06/2024
  2. B. 2031 2024/06/01 06/01/2024
  3. C. 2031 2024/06/01 01/06/2024
  4. D. 2030 2024/06/01 01/06/2024

Correct answer: C. 2031 2024/06/01 01/06/2024

map(int, ...) turns the three parts into numbers, and 2024 + 6 + 1 is 2031. The format %02d pads to two digits and %04d pads the year to four.

More Python Programming questions

Exams that ask this topic