In: Computer Science
>
* 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 be between -40 and 40, and high must be greater than low.
Print the following messages:
* 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
NUMS=3
print("--== Python Temperature Analyzer ==--",end=' ')
for i in range(NUMS):
print("Enter the high value for day %d:" %(i+1),end=' ')
high=int(input())
print("Enter the low value for day %d:" %(i+1),end=' ')
low=int(input())
while (high<41 and low>-41 and high>low)==False:
print("Incorrect values, temperatures must be in the range -40 to 40, high must be greater than low.")
print("Enter the high value for day %d:" %(i+1),end=' ')
high=int(input())
print("Enter the low value for day %d:" %(i+1),end=' ')
low=int(input())
OUTPUT EXAMPLE
--== 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
#If have any query any in comment box