Print today's date and a calendar for current month.
python
from calendar import TextCalendar
from datetime import date
t = date.today()
print("Today is", t)
print() # prints empty line
TextCalendar().prmonth(t.year, t.month)
Run
lamr code cal.py --all
to get this code with excercises.
Excercises
- Print calendar for the next month.
- Change the first day the week in calendar to Sunday.
- Implement
print_month(year: int, month: int)
function to print calendar. - Change output format for today's date.
- Print the date of your birthday.
- Find out what day of the week your actual birthday was.
References
- Documentation for
datetime
. URL: https://docs.python.org/3/library/datetime.html#available-types - Documentation for
calendar.TextCalendar
. URL: https://docs.python.org/3/library/calendar.html#calendar.TextCalendar