Have to write some code that defines a function that will work with two or three arguments.
The function should take three parameters:
- temperature, a float
- weather, a string
- is_celsius, a boolean
The function should return True if temperature is below freezing (32 if is_celsius is False, 0 if is_celsius is True) or if weather is "snowy". Otherwise, it should return False.
Note, however, that is_celsius should be an optional argument. If the function call does not supply a value for is_celsius, assume it is True.
I wrote this
def snowed_in(temperature, weather, **cels):
if weather =="snowy":
return True
elif weather=="sunny":
if 'is_celsius = False' in cels:
if temperature<32:
return True
elif 'is_celsius = True' in cels:
if temperature<0:
print ('ad')
return True
elif 'is_celsius = True' not in cels:
if temperature<0:
return True
else:
return False
and for the following calls
print(snowed_in(15, "sunny")) #Should print False
print(snowed_in(15, "sunny",is_celsius = False)) #Should print True
print(snowed_in(15, "snowy",is_celsius = True)) #Should print True
I'm getting
None
None
True
Can someone help me find what's wrong with my code?