The program prompts the user to input the week of the year and the year in the format "YYYY" and "WW", respectively. It then initializes a variable first_mon to represent the first Monday of the year, which is always in the first week.
The program uses the datetime module to parse the input string into a datetime object with the specified year and week, and the first Monday of the year. It then prints the date of the first Monday of the input week and year.
import datetime week = input("Enter the Week of the Year :") year = input("Enter the Year :") first_mon = '1' date = datetime.datetime.strptime(year + week + first_mon, "%Y%W%w") print(date.date())
Enter the Week of the Year :39 Enter the Year :2022 2022-09-26
Learn All in Tamil © Designed & Developed By Tutor Joes | Privacy Policy | Terms & Conditions