Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

howmanydays python

# python program Find number of
# times every day occurs in a Year
  
 
import datetime
import calendar
  
def day_occur_time(year):
     
    # stores days in a week
    days = [ "Monday", "Tuesday", "Wednesday", 
           "Thursday",  "Friday", "Saturday",
           "Sunday" ]
     
    # Initialize all counts as 52
    L = [52 for i in range(7)]
     
    # Find the index of the first day
    # of the year
    pos = -1
    day = datetime.datetime(year, month = 1, day = 1).strftime("%A")
    for i in range(7):
        if day == days[i]:
            pos = i
             
    # mark the occurrence to be 53 of 1st day
    # and 2nd day if the year is leap year
    if calendar.isleap(year):
        L[pos] += 1
        L[(pos+1)%7] += 1
         
    else:
        L[pos] += 1
         
     
    # Print the days
    for i in range(7):
        print(days[i], L[i])
      
  
# Driver Code
year = 2019
day_occur_time(year)
Comment

PREVIOUS NEXT
Code Example
Python :: "DO_NOTHING" is not defined django 
Python :: print is not working in python 
Python :: pytest handling muliple cases 
Python :: hack twitter with python 
Python :: rtdpy ncstr 
Python :: RuntimeError: DataLoader worker (pid(s) 13615) exited unexpectedly 
Python :: circular reference detected python repl.it 
Python :: train object detection model 
Python :: How to count number of distinct elements in specified axis 
Python :: rename_and_convert_all_images_at_folder 
Python :: django column to have duplicate of other 
Python :: round to nearest multiple of 5 python from both end 
Python :: connect two mathod to the same button in pyq5 
Python :: python get function from string name 
Python :: generator expressions python 
Python :: python3 netifaces get current interface 
Python :: python: dunder init method 
Python :: gdal user with anaconda 
Python :: if list is null python apply any function site:stackoverflow.com 
Python :: inspect last 5 rows of dataframe 
Python :: fetch member by id discord.py 
Python :: convert python to java online 
Python :: python iterate through list by chunks 
Python :: flask request file upload to dropbox 
Python :: hi guys 
Python :: mechanize python #2 
Python :: struct trong Python 
Python :: accumulate sum of elements in list 
Python :: close window tkiinter 
Python :: loader.py line 19 in get_template 
ADD CONTENT
Topic
Content
Source link
Name
9+9 =