diff --git a/BasicPythonScripts/Finding Number of Days in a Month/Images/Day Finder.png b/BasicPythonScripts/Finding Number of Days in a Month/Images/Day Finder.png new file mode 100644 index 000000000..d51e81aec Binary files /dev/null and b/BasicPythonScripts/Finding Number of Days in a Month/Images/Day Finder.png differ diff --git a/BasicPythonScripts/Finding Number of Days in a Month/Images/Number_of_days.png b/BasicPythonScripts/Finding Number of Days in a Month/Images/Number_of_days.png new file mode 100644 index 000000000..10cfe5636 Binary files /dev/null and b/BasicPythonScripts/Finding Number of Days in a Month/Images/Number_of_days.png differ diff --git a/BasicPythonScripts/Finding Number of Days in a Month/README.md b/BasicPythonScripts/Finding Number of Days in a Month/README.md new file mode 100644 index 000000000..703d8cf5c --- /dev/null +++ b/BasicPythonScripts/Finding Number of Days in a Month/README.md @@ -0,0 +1,44 @@ +# Finding the Number of Days in a Month +## Aim :- Finding the Number of Days in a Month + +## Purpose :- + -To find the number of days in a month. + +## WorkFlow :_ + +## Script used in Finding the Number of Days in a Month +-First we will import datetime libray +-Then def main function in which user have to give input as year and month. +-The strptime() method creates a datetime object from the given string. +-THen it will call the days_finder() function and perform certain operation and give output. + +### main() :- It will take input from user as year and month and call other function. + +### days_finder :-It will perform operation and give the desired output . + +### choice :- It choice selection function used to make decision. + +## Compilation steps:- + +-import datetime libray to finding the name of month + +-days_finder() is function that will be called for finding the number of days in mmonth. + +-After performing the operation , I gave the option whether user want to continue or exit. + +-If want to co continue enter 1 or else to Exit. + + +## Setup instructions +-User needs any python id and compiler to execute the program. + + +## Display images/gifs/videos of output/result of your script so that users can visualize it +https://github.com/Ashu-1309/Awesome_Python_Scripts/blob/829ca05abf0f10c77fdd060db4ced2d544f30dd1/BasicPythonScripts/Finding%20Number%20of%20Days%20in%20a%20Month/Images/Day%20Finder.png + + + +## Author(s) +ASHUTOSH KUMAR SAW
+LGMSOC
+CONTRIBUTOR diff --git a/BasicPythonScripts/Finding Number of Days in a Month/days_finder.py b/BasicPythonScripts/Finding Number of Days in a Month/days_finder.py new file mode 100644 index 000000000..e13cf168d --- /dev/null +++ b/BasicPythonScripts/Finding Number of Days in a Month/days_finder.py @@ -0,0 +1,41 @@ +# This code will be used to find out the Numbers of day in a month. +print(" -- This code is used to find the Number of days in a Month-- ") +days_finder.py +import datetime + + +def days_finder(month_number, year): #defining the functon to find the number of days in a month + leap = 0 #assigning value + print(month_number) + list_31 = [1, 3, 5, 7, 8, 10, 12] # Listing Out month number having 31 days + list_30 = [4, 6, 9, 11] # Listing Out month number having 31 days + if year % 4 == 0: # Condition checking for leap year + leap = 1 + if month_number in list_30: # Condition check for 30 days + number_of_days = 30 + elif month_number in list_31: # Condition checking for 31 days + number_of_days = 31 + else: #Condition checking for 28 days + number_of_days = 28 + leap # if month is feb and its leap year than leap + 1 so it will become 29 days + return number_of_days + + +def main(): # main function + year = int(input("Enter the year ")) # user input (year ) + month_number = (input(' Enter the Name of Month ')) #user input (month) + datetime_object = datetime.datetime.strptime(month_number, "%m") # calling datetime libray for month finding + + month_name = datetime_object.strftime("%B") # This Section will give month name as output + month_number = int(month_number) + + print("The Number of days in ",month_name ," is " ,days_finder(month_number, year)) + + choice=int(input("Enter 1 to Continue or else to exit ")) + if choice == 1: + main() + else: + exit + + +main() + diff --git a/BasicPythonScripts/Finding Number of Days in a Month/requirements.txt b/BasicPythonScripts/Finding Number of Days in a Month/requirements.txt new file mode 100644 index 000000000..3851aeeb5 --- /dev/null +++ b/BasicPythonScripts/Finding Number of Days in a Month/requirements.txt @@ -0,0 +1,8 @@ +##requirement + + import datetime + + + use strptime method to create a datetime object + +%B is used to give Full Month Name.