SummerTime = None; temperature = None # variables
while SummerTime != "y" and SummerTime != "n" : # initializing SummerTime
SummerTime = input("Is it Summer(y/n): ")
while type(temperature) != int : # initializing temperature
try : temperature = int(input("Temperature in degrees: "))
except : continue
if SummerTime == "y" : # responding
if 60 <= temperature <= 100 : print("Squirrels are safe to play!")
else : print("Squirrels should not play!")
elif 60 <= temperature <= 90 : print("Squirrels are safe to play!")
else : print("Squirrels should not play!")
Python Console:
Is it Summer(y/n): n
Temperature in degrees: 67
Squirrels are safe to play!
Process finished with exit code 0
Comments
Leave a comment