Answer to Question #83381 in Python for Andrea Murphy

Question #83381
3. Squirrels: The squirrels in Palo Alto spend most of the day playing. In particular, they play if the temperature is between 60 and 90 (inclusive). Unless it is summer, then the upper limit is 100 instead of 90. Given an int temperature from the user print out to the user if the squirrels can play or not. (You may want to ask if it is summer)
1
Expert's answer
2018-11-29T12:08:11-0500

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

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS