belongs to collection: Python Date and Time Exercises
Given:
given_date = datetime(2020, 7, 26)
Expected output:
Sunday
Solution1:
from datetime import datetime given_date = datetime(2020, 7, 26) # to get weekday as integer print(given_date.today().weekday()) # To get the english name of the weekday print(given_date.strftime('%A'))
Solution2:using calendar module
import calendar from datetime import datetime given_date = datetime(2020, 7, 26) weekday = calendar.day_name[given_date.weekday()] print(weekday)
total answers (1)
start bookmarking useful questions and collections and save it into your own study-lists, login now to start creating your own collections.
Solution1:
Solution2:using calendar module
need an explanation for this answer? contact us directly to get an explanation for this answer