Create a date and read its parts

EasyDatetime Programs · 1 of 20

Write a Python program to create a date and print its year, month, day and weekday.

Advertisement
Output
2026-11-02 2026 11 2 Monday

Approach

  1. date(y, m, d) and its attributes.

Solution

Python
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.

More datetime programs

← All 20 Datetime Programs

Leave a Comment