ProgrammingModerateGATE CS · Product-company placement

What is printed?

What is printed?
s = "2024-01-15"
y, m, d = map(int, s.split("-"))
print(y + m + d, f"{d:02d}/{m:02d}/{y}", s[5:7] == "01")
  1. A. 2040 15/1/2024 True
  2. B. 20240115 15/01/2024 True
  3. C. 2040 15/01/2024 False
  4. D. 2040 15/01/2024 True

Correct answer: D. 2040 15/01/2024 True

map(int, ...) converts each part, and int('01') is 1, so the sum is 2024 + 1 + 15 = 2040. :02d pads to two digits. s[5:7] is '01'.

More Python Programming questions

Exams that ask this topic