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))- A. 2031 2024-06-02 01/06/2024
- B. 2031 2024/06/01 06/01/2024
- C. 2031 2024/06/01 01/06/2024
- 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
- What is printed? python print('%d' % 1020, '%.3e' % (270), len('%d' % (2100)), '%x' % (270))
- What is printed? python print(int(float('9007199254740993')) == 9007199254740993, float('9007199254740993') == 9007199254740992.0…
- What is printed? python nums = [3, 1, 4, 1, 5, 9, 2, 6] print(sorted(nums)[len(nums) // 2], sorted(nums)[(len(nums) - 1) // 2], sum(nums)…
- What is printed? python print(sum([0.1] 3) == 0.3, sum([0.1] 3, 0.0) == 0.30000000000000004, sum([1e100, 1.0, -1e100]))
- What is printed? python print(-(2 3) 2, (-2) 3 2, -2 -1, 0)
- What is printed? python print(7 & 3 << 1, 7 & (3 << 1), 6 | 1 << 2, (6 | 1) << 2)