Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Module help
#10
Prompt:
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


I have submitted:

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,)
Results:
Output:
The temperature is 40 The temperature is 0 The temperature is 25 The temperature is 2 The temperature is 39 The temperature is 62
I have changed the location of the parenthesis to multiple places however still get incorrect numbers ran in the output...

Any help is appreciated!!
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