Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Module help
#1
You have a thermostat that allows you to set the room to any temperature between 40 and 89 degrees.

The thermostat can be adjusted by turning a circular dial. For instance, if the temperature is set to 50 degrees and you turn the dial 10 clicks toward the left, you will set the temperature to 40 degrees. But if you keep turning 1 click to the left (represented as -1) it will circle back around to 89 degrees. If you are at 40 degrees and turn to the right by one click, you will get 41 degrees. As you continue to turn to the right, the temperature goes up, and the temperature gets closer and closer to 89 degrees. But as soon as you complete one full rotation (50 clicks), the temperature cycles back around to 40 degrees.

Write a program that calculates the temperature based on how much the dial has been turned. The number of clicks (from the starting point of 40 degrees) is contained in a variable. You should print the current temperature for each given click variable so that your output is as follows:

The temperature is 40
The temperature is 89
The temperature is 64
The temperature is 41
The temperature is 89
The temperature is 40


Below is my submission:

#For each click variable, calculate the temperature and print it as shown in the instructions

click_1 = 0
# TODO calculate the temperature, and report it back to the user

click_2 = 49
# TODO calculate the temperature, and report it back to the user

click_3 = 74
# TODO calculate the temperature, and report it back to the user

click_4 = 51
# TODO calculate the temperature, and report it back to the user

click_5 = -1
# TODO calculate the temperature, and report it back to the user

click_6 = 200
# TODO calculate the temperature, and report it back to the user

total_clicks = ['0' , '49' , '74' , '51' , '-1' , '200']

for count in total_clicks:
    
    count = int(count)
    
    count = count + 40 % 89
        
    print("The temperature is" ,count,)
However, the error I keep getting back is:

✖ ︎You should have printed this:


Output:
The temperature is 40 The temperature is 89 The temperature is 64 The temperature is 41 The temperature is 89 The temperature is 40
But you actually printed this:


The temperature is 40
The temperature is 89
The temperature is 114
The temperature is 91
The temperature is 39
The temperature is 240
Reply


Messages In This Thread
Module help - by wak_stephanie - Jul-22-2018, 10:57 PM
RE: Module help - by micseydel - Jul-27-2018, 03:54 AM
RE: Module help - by perfringo - Jul-27-2018, 07:14 AM
RE: Module help - by ichabod801 - Jul-27-2018, 12:59 PM
RE: Module help - by Larz60+ - Jul-22-2018, 11:17 PM
RE: Module help - by wak_stephanie - Jul-22-2018, 11:33 PM
RE: Module help - by Larz60+ - Jul-22-2018, 11:41 PM
RE: Module help - by ichabod801 - Jul-23-2018, 12:42 AM
RE: Module help - by wak_stephanie - Jul-23-2018, 03:19 AM
RE: Module help - by ichabod801 - Jul-23-2018, 03:25 AM
RE: Module help - by wak_stephanie - Jul-23-2018, 03:34 AM
RE: Module help - by ichabod801 - Jul-23-2018, 01:49 PM
Module help - by stangerbot342 - Jul-26-2018, 09:57 PM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020