temp (mini)

Python Morsels Mini Exercise

Command-line program to rate a given temperature

6 hints 5 solutions 200 users solved 21 reviews

I'd like you to write a program temp.py that accepts a temperature and prints a phrase describing the temperature.

The given temperature will be in Fahrenheit and should print one of these three statements:

  1. Print "Too hot" if the temperature is above 80
  2. Print "Too cold" if the temperature is below 65
  3. Print "Quite nice" if the temperature is between 65 and 80

Here's how your program should work:

$ python temp.py 80
Quite nice
$ python temp.py 82
Too hot
$ python temp.py 60
Too cold
$ python temp.py 70
Quite nice

Note that this program should not prompt the user for input, but instead should accept a single command-line argument.

You can assume the temperature is a positive two-digit number.

This is just a preview of the problem statement.

This mini exercise includes 6 hint links. This mini exercise has no bonuses.

To solve this exercise, sign in to your Python Morsels account.

A learning habit for experienced Pythonistas

Profile picture of Trey

My name is Trey Hunner and I hold Python trainings for teams. I've spent countless hours refining my most interesting Python exercises into Python Morsels, a Python skill-building platform for folks who already know Python. Python Morsels is design to help you deepen your Python skills every week.

Sign up for Python Morsels to access this exercise and many more.

Join Python Morsels ✨