Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

def get _ season ( month , day ) : month = month.lower ( ) if month not in [ ' january ' , 'february',

def get_season(month, day):
month = month.lower()
if month not in ['january', 'february', 'march', 'april', 'may', 'june', 'july', 'august', 'september', 'october', 'november', 'december']:
return "Invalid"
seasons ={
"Spring": [(3,20),(6,20)],
"Summer": [(6,21),(9,21)],
"Autumn": [(9,22),(12,20)],
"Winter": [(12,21),(12,31),(1,1),(3,19)]
}
month_num ={
"january": 1, "february": 2, "march": 3, "april": 4,
"may": 5, "june": 6, "july": 7, "august": 8,
"september": 9, "october": 10, "november": 11, "december": 12
}
if (month, day)>=("march",20) or (month, day)<=("june",20):
return "Spring"
elif (month, day)>=("june",21) or (month, day)<=("september",21):
return "Summer"
elif (month, day)>=("september",22) or (month, day)<=("december",20):
return "Autumn"
else:
return "Winter"
def main():
month = input("Enter the month: ")
day = int(input("Enter the day: "))
season = get_season(month, day)
if season == "Invalid":
print("Invalid month or day.")
else:
print(f"The season for {month}{day} is {season}.")
if __name__=="__main__":
main()

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Logistics Lifeline Supply Chain Strategies

Authors: Ehsan Sheroy

1st Edition

7419377502, 978-7419377503

More Books

Students also viewed these Databases questions

Question

Persuasive Speaking Organizing Patterns in Persuasive Speaking?

Answered: 1 week ago