Given a year .Your task is to find the number of every day in a year ie.number of Monday, Tuesday, Wednesday, Thrusday, Friday, Saturday, Sunday in that given year.
Input: 2019 Output: Monday-52 Tuesday-53 Wednesday-52 Thrusday-52 Friday-52 Saturday-52 Sunday-52 Input: 2024 Output: Monday-53 Tuesday-53 Wednesday-52 Thrusday-52 Friday-52 Saturday-52 Sunday-52
Observations: We have to make some key observations. The first one will be that there are at least 52 weeks in a year, so every day will occur at least 52 times in a year. As 52*7 is 364 so the day occurring on the 1st January of any year will occur 53 times and if the year is a leap year then the day on the 2nd January will also occur 53 times.
Approach: Create a list with size 7 and having an initial value of 52 as the minimum number of occurrences will be 52. Find the index of the first day. Calculate the number of days whose occurrence will be 53.
Below is the implementation.
Monday 52 Tuesday 52 Wednesday 52 Thursday 52 Friday 53 Saturday 53 Sunday 52
Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.
To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course.
- Python program to find the first day of given year
- Python - Convert day number to date in particular year
- Python | Check if k occurs atleast n times in a list
- Python program to check if given value occurs atleast k times
- Python | Check if any element occurs n times in given list
- Python - Test if K occurs N consecutive times
- Program to calculate Dooms Day for a year
- Python - Test if Substring occurs in specific position
- Python program to find day of the week for a given date
- Python program to find birthdate on the same day you were born
- Python | Find the Number Occurring Odd Number of Times using Lambda expression and reduce function
- Python | Pandas Timestamp.day
- Problems not solved at the end of Nth day
- Python | Pandas DatetimeIndex.day
- Python | Pandas Period.day
- Python | Pandas PeriodIndex.day
- Python | Pandas Series.dt.day
- PyQt5 QCalendarWidget - Setting First Day of Week
- PyQt5 QCalendarWidget - Getting First Day of Week
- Get Day from date in Pandas - Python
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.