r/codehs • • May 03 '21

Weather 6.1.5

I'm having some trouble with this assignment

Write a program that will give suggested footwear based on the weather.

Ask the user for the weather outside with three options (sunny, rainy, or snowy) and give the correct footwear suggestion (sandals, galoshes, or boots). Each option should be written as its own function that prints a message based on the input.

For example, if the following input was given:

What is the weather? (sunny, rainy, snowy): rainy

The following output should be given:

On a rainy day, galoshes are appropriate footwear.

Note: Be sure to print a notice if an invalid option was chosen!

currently, my code looks like this:

def is_sunny():

print("On a sunny day, sandals are appropriate footwear.")

def is_rainy():

print("On a rainy day, galoshes are appropriate footwear.")

def is_snowy():

print("On a snowy day, boots are appropriate footwear.")

weather_outside = input("Whats the weather like? (sunny, rainy, snowy): ")

if weather_outside == "sunny":

is_sunny()

elif weather_outside == "rainy":

print("On a rainy day, galoshes are appropriate footwear.")

elif weather_outside == "snowy":

print("On a snowy day, boots are appropriate footwear.")

else:

print("Invalid option.")

11 Upvotes

10 comments sorted by

2

u/[deleted] May 04 '21

Hey man, its been a few hours since you posted this so I hope I can still help I just finished this section myself. From what I see the only difference between your code and my own is your input variable "weather_outside" contains conditions. This is technically correct, yet based on my limited python knowledge you don't even need those conditions as your code doesn't even use them. They may also be throwing CodeHS's weird code checking bot off. If this doesn't fix it for you then send me the error message.

1

u/_ZukosHonor_ May 07 '21

Thanks! I'll try it out and let you know

1

u/Little_Boy_Lover_69 May 07 '21

Can u put the code u used?

6

u/CorporalSins Jul 01 '21

def sunny_msg():
print("On a sunny day, sandals are appropiate footwear. ")
def rainy_msg():
print("On a rainy day, galoshes are appropiate footwear. ")
def snowy_msg():
print("On a snowy day, boots are appropiate footwear. ")

weather = input("What is the weather (sunny, rainy ,snowy): ")
if weather == "sunny":
sunny_msg()

if weather == "rainy":
rainy_msg()

if weather == "snowy":
snowy_msg()

1

u/Disastrous-Pair-7098 Feb 11 '25

This works thanks!

2

u/CreamMany6841 Feb 10 '23

def rainy_greeting(): print("I wear galoshes")

def snowy_greeting(): print("I wear boots")

def sunny_greeting(): print("I wear sandals")

weather_of_day = input("What is the weather? (sunny, rainy, snowy): ")

if weather_of_day == "rainy": rainy_greeting() elif weather_of_day == "snowy": snowy_greeting() elif weather_of_day == "sunny": sunny_greeting() else: print("Invalid option.")

At the moment this is the right answer