Part 1: Computing the number of days in a month
write a function called "days_in_month" in python 3 that takes two integers: a year and a month. The function should return the number of days in that month. assume that both inputs are valid the month input is a number between 1 and 12 and the year input is a number between 0000 and yyyy.
You do not need to check that the inputs are within the proper ranges. You can assume that any function that calls this one will already have checked that. Make sure you account for leap year:
#my first attempt....
def days_in_month(year, month):
"""
Inputs:
year - an integer between [login to view URL] and [login to view URL]
representing the year
month - an integer between 1 and 12 representing the month
Returns:
The number of days in the input month.
"""
if (month == 4) or (month == 6) or (month == 9) or (month == 11):
days_in_month = 30
if (month == 1) or (month == 3) or (month == 5) or (month == 7)or (month == 8) or (month == 10) or (month == 12):
days_in_month = 31
if (month == 2):
bool isLeapyear = (year % 4 == 0) and (year % 100 != 0) or (year % 400 == 0) #boolean formula for Leap year
if(isLeapyear):
days_in_month = 29
else:
days_in_month = 28
return (days_in_month)
One way in which to determine the number of days in a month is to subtract the first of the given month from the first of the next month. The result should be the number of days in the given month.
Part 2: Checking if a date is valid
write another function called "is_valid_date" that takes three integers: a year, a month, and a day. The function should return "True" if that date is valid and 'False" otherwise. This function should not assume that the inputs are valid. Rather, this function should check that all three inputs combine to form a valid date, with a year between [login to view URL] [login to view URL] and [login to view URL], a month between 1 and 12, and a day between 1 and the number of days in the given month. Notice that the function days_in_month that you wrote for Part 1 will be useful here!
Part 3: Computing the number of days between two dates
Now that we have a way to check if a given date is valid, you will write a function called days_between that takes six integers (year1, month1, day1, year2, month2, day2) and returns the number of days from an earlier date (year1-month1-day1) to a later date (year2-month2-day2). If either date is invalid, the function should return 0. Notice that you already wrote a function to determine if a date is valid or not! If the second date is earlier than the first date, the function should also return 0.
Be sure to first check that all of the inputs are valid. Do not repeat code. Make sure you reuse things that you have already written.
Make sure to check the cases where the function is supposed to return 0.
Part 4: Calculating a person's age in days
Finally, you will write a function called "age_in_days" that takes three integers as input: the year, month, and day of a persons birthday. The function should return that person's age in days as of today. The function should return 0 if the input date is invalid (remember you have a function to check that!). The function should also return 0 if the input date is in the future.
I have read your project and I am an expert in this field. I can do this for you within due time and honestly. I also have a few questions to discuss. Kindly contact me and we will discuss time and budget. Thanks
$20 USD 7 napon belül
4,9
(12 értékelés)
3,9
3,9
4 szabadúszó adott átlagosan $23 USD összegű árajánlatot erre a munkára
*** Project : Collection data with date ***
I read your project description very carefully.
I have a deep understanding and experience in the areas of Python that you mentioned.
I've previously worked on the similar projects for another employers.
Check my past reviews and profiles
So, I would like to go through more specific discussions with you to provide successful results.
Thank you, from Mohamed F
✔Able to start right now and finish within one day
Hi
I have read your project description and understood the requirements of what you want.
I have built many apps using python, so have lots of experience.
I'm ready to start your project right now and able to lead your project to success asap.
Thank you.
Hello Potential Client.
I am professional software developer with 10 years experiences of Python.
I have developed many Project.
I can start working right now and can do it successfully.
I’m waiting for your positive response.
Best regards