Python Practice › Datetime Programs › Program 1
Create a date and read its parts
Write a Python program to create a date and print its year, month, day and weekday.
Output
2026-11-02 2026 11 2 Monday
Approach
date(y, m, d)and its attributes.
Solution
from datetime import date d = date(2026, 11, 2)print(d, d.year, d.month, d.day, d.strftime("%A"))Output
2026-11-02 2026 11 2 Monday
Learn the concept
New to this topic? Read the lesson, then come back.