Question

In: Computer Science

PYTHON 1- First, initialize the constant NUMS as 3: NUMS=3 2- Print the title of the...

PYTHON

1- First, initialize the constant NUMS as 3: NUMS=3
2- Print the title of the application.
>---=== Python Temperature Analyzer ===---<
3- Using a for loop, prompt the user to enter the high and low values for each of NUMS days. The values entered must be between -40 and 40, and high must be greater than low.
Print the following messages:
>
* Read the high value.
>
Enter the high value for day 1:
< (or day 2, or day 3)
Enter the low value for day 1:
< (or day 2, or day 3)

* Read the low value.
IMPORTANT: You may only declare two (2) int type variables for the high and low values
4- Useanestedwhile(ordo-while)looptoanalyzetheresults,highmustbegreaterthan low, high must be less than 41, low must be greater than -41
*If any entry is incorrect, prompt the user to enter again until the entries pass the tests:
>
<
Then prompt again for the high and low temperatures for the day.
OUTPUT EXAMPLE (Red numbers show the input)
--== Python Temperature Analyzer ==-- Enter the high value for day 1: 8
Enter the low value for day 1: -2
Enter the high value for day 2: 41
Enter the low value for day 2: -4
Incorrect values, temperatures must be in the range -40 to 40, high must be greater than low.
Enter the high value for day 2: 9
Enter the low value for day 2: -4
Enter the high value for day 3: 5
Enter the low value for day 3: 11
Incorrect values, temperatures must be in the range -40 to 40, high must be greater than low.
Enter the high value for day 3: 11 Enter the low value for day 3: 5

Solutions

Expert Solution

Below is a screen shot of the python program to check indentation. Comments are given on every line explaining the code.

Below is the output of the program:

Below is the code to copy:
#CODE STARTS HERE----------------
NUMS = 3 #Constant
print("--===Python Temperature Analyzer===--")

day = 0
while day<NUMS: #Outer while loop to collect data for NUMS days
   while True: #Inner while loop which loops until a valid input is given
      #Input high values
      t_high = int(input("Enter the high values for day "+str(day+1)+": "))
      #Input low values
      t_low = int(input("Enter the low values for day "+str(day+1)+": "))
      #Check if the input values are valid
      if t_low>t_high or t_low< -40 or t_high>40:
         print("Incorrect values, temperatures must be in the range -40 to 40, high must be greater than low.")
         continue #Loop again if values are invalid
      break #Break loop if input values are valid
   day+=1 #Update day counter
#CODE ENDS HERE-----------------

Related Solutions

* Read the high value. > 1- First, initialize the constant NUMS as 3: NUMS=3 2-...
* Read the high value. > 1- First, initialize the constant NUMS as 3: NUMS=3 2- Print the title of the application. >---=== Python Temperature Analyzer ===---<. 3- Using a for loop, prompt the user to enter the high and low values for each of NUMS days. The values entered must be between -40 and 40, and high must be greater than low. Print the following messages: > Enter the high value for day 1: < (or day 2, or...
> * Read the high value. > 1- First, initialize the constant NUMS as 3: NUMS=3...
> * Read the high value. > 1- First, initialize the constant NUMS as 3: NUMS=3 2- Print the title of the application. >---=== Python Temperature Analyzer ===---< Enter the high value for day 1: < (or day 2, or day 3) Enter the low value for day 1: < (or day 2, or day 3) 3- Using a for loop, prompt the user to enter the high and low values for each of NUMS days. The values entered must...
using python 3 1. Two-line input: print a prompt (e.g Enter your first name) and then...
using python 3 1. Two-line input: print a prompt (e.g Enter your first name) and then assign the input to a variable print ("Enter your first name")# the word prompt is the message the user should see firstName = input() print (firstName)
Python #For question 1 and 2 you may not use ''' ''' Question 1 Print the...
Python #For question 1 and 2 you may not use ''' ''' Question 1 Print the messages below without using variables. Output must be 2 lines identical to below: What is the snake's favorite language? "I love Python", said the snake. Question 2 Write a python statements to match the 5 lines of output below. Use a single print statement to produce the list of 4 languages The 3 most popular programming languages of 2020 are: 1.         Python 2.         Javascript 3.         Java 4.         C#...
Write a program in Python that will print first 100 numbers of the following series: 0,...
Write a program in Python that will print first 100 numbers of the following series: 0, 1, 1, 2, 3, 5, 8……..
2) create a python program that uses a for loop and range to print out the...
2) create a python program that uses a for loop and range to print out the values 10 8 6 4 2 3) Create a python program that yses a for loop to print out ["bob","al","bert"]
PYTHON ASSIGNMENT Problem: (1) The  __init__ method should initialize the values of the instance variables. Here is...
PYTHON ASSIGNMENT Problem: (1) The  __init__ method should initialize the values of the instance variables. Here is the beginning of __init__: def __init__(self, the_hr, the_min, the_sec): self.hr = the_hr # Also initialize min and sec. (2) Include a __str__ method that returns the current state of the clock object as a string. You can use the string format method format like this: return "{0:02d}:{1:02d}:{2:02d}".format(self.hr, self.min, self.sec) (3) When the tick method is executed, add one to sec. If the resulting value...
2. Add a title comment block to the top of the new Python file using the...
2. Add a title comment block to the top of the new Python file using the following form # A brief description of the project 3. Ask user - to enter the charge for food 4. Ask user - to enter theTip for server ( remember this is a percentage , the input therefore should be decimal. For example, for a 15% tip, 0.15 should be entered) 5. Ask user - to enter the Tax amount ( this is a...
Use Python: Develop neurons and print truth table of the following 2-input logic gates: AND, OR,...
Use Python: Develop neurons and print truth table of the following 2-input logic gates: AND, OR, NAND, NOR, XOR, XNOR and 1-input NOT gate (Notice: use Markdown to explain how you developed a neuron, and to insert images showing the truth table of logic gates before coding)
(IN PYTHON 3) Complete the following two tasks: 1. Words like first, second, and third are...
(IN PYTHON 3) Complete the following two tasks: 1. Words like first, second, and third are referred to as ordinal numbers. In this exercise, you will write a function that takes an integer as its only parameter and returns a string containing the appropriate English ordinal number as its only result. Your function must handle the integers between 1 and 12 (inclusive). It should return an empty string if a value outside of this range is provided as a parameter....
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT