Westonci.ca is the ultimate Q&A platform, offering detailed and reliable answers from a knowledgeable community. Explore thousands of questions and answers from a knowledgeable community of experts on our user-friendly platform. Join our platform to connect with experts ready to provide precise answers to your questions in different areas.
Sagot :
Answer:
This is in python
Explanation:
Alter my code if you need anything changed. (You may need to create a new function to add a day to February if necessary)
months = [31,28,31,30,31,30,31,31,30,31,30,31]
monthNames = ['january','february','march','april','may','june',
'july','august','september','october','november','december']
array = []
def test(y,m,d): #Does not account for leap-year. Make a new function that adds a day to february and call it before this one
if m.lower() not in monthNames or y < 1 or d > 31:
if m.lower() == "april" or m.lower() == "june" or m.lower() == "september" or m.lower() == "november" and d > 30:
return None
elif m.lower() == "february" and d > months[1]:
return None
return None
num = monthNames.index(m.lower()) #m should be the inputted month
months[num] = d
date = months[num]
for n in range(num):
array.append(months[n])
tempTotal = sum(array)
return tempTotal + date
x = int(input("Enter year: "))
y = input("Enter month: ")
z = int(input("Enter day: "))
print(f"{y.capitalize()} {z} is day {test(x,y,z)} in {x}")
We appreciate your time. Please come back anytime for the latest information and answers to your questions. We hope you found this helpful. Feel free to come back anytime for more accurate answers and updated information. Thank you for visiting Westonci.ca. Stay informed by coming back for more detailed answers.