Question

In: Computer Science

Write a Python program to read in the temperatures for ten consecutive days in Celsius and...

Write a Python program to read in the temperatures for ten consecutive days in Celsius and store them into an array. The entire array should then be displayed. Next each temperature in the array should be converted to Fahrenheit and the entire array should be again be displayed. The formula for converting Celsius to Fahrenheit is °F = (°C × 1.8) + 32. Finally, the number of cool, warm and hot days should be counted and the number of each type of days should be displayed. You should decide on the thresholds for determining whether a day is cool, warm or hot.

Solutions

Expert Solution

The above code is implemented in python

# Function to display the temperature stored in list
def display_temp(a,s):
    j=1
    for i in range(len(a)):
        print("The temperature of day ",j," is",a[i],s)
        j+=1
    print()


# Function to convert celcius to Farenheit        
def convert_farenheit(c):
    return (c*1.8)+32


# Program starts here
print("Enter the temperature of 10 consective days in celcius")
arr = list(map(int,input().split())) # This is used to take space seperated input
display_temp(arr,"ᴼC") # display_temp function is called 

# This loop is used to convert every element from celcius to farenheit
for i in range(len(arr)):
    arr[i]=convert_farenheit(arr[i]) # conversion is done using convert_farenheit function defined above

    
display_temp(arr,"ᴼF") # array is displayed


# The temperature between 32 degree Farenheit to 92 degree Fareheiti is considered as cold
# The temperature between 93 degree Farenheit to 152 degree Fareheiti is considered as warm
#The temperature between 153 degree Farenheit to 212 degree Fareheiti is considered as hot
# Threshold can be different
cold=0
warm=0
hot=0

for i in arr:
    if i>=32 and i<=92:
        cold+=1
    elif i>=93 and i<=152:
        warm+=1
    else:
        hot+=1

print("Number of Cold Days is:",cold)
print("Number of Warm Days is:",warm)
print("Number of Hot Days is:",hot)
    

Output

Enter the temperature of 10 consective days in celcius
45 23 12 87 22 11 8 66 92 44
The temperature of day 1 is 45 ᴼC
The temperature of day 2 is 23 ᴼC
The temperature of day 3 is 12 ᴼC
The temperature of day 4 is 87 ᴼC
The temperature of day 5 is 22 ᴼC
The temperature of day 6 is 11 ᴼC
The temperature of day 7 is 8 ᴼC
The temperature of day 8 is 66 ᴼC
The temperature of day 9 is 92 ᴼC
The temperature of day 10 is 44 ᴼC

The temperature of day 1 is 113.0 ᴼF
The temperature of day 2 is 73.4 ᴼF
The temperature of day 3 is 53.6 ᴼF
The temperature of day 4 is 188.6 ᴼF
The temperature of day 5 is 71.6 ᴼF
The temperature of day 6 is 51.8 ᴼF
The temperature of day 7 is 46.4 ᴼF
The temperature of day 8 is 150.8 ᴼF
The temperature of day 9 is 197.6 ᴼF
The temperature of day 10 is 111.2 ᴼF

Number of Cold Days is: 5
Number of Warm Days is: 3
Number of Hot Days is: 2


Related Solutions

Design a Python program to prompt the user for temperatures for ten consecutive days in Celsius...
Design a Python program to prompt the user for temperatures for ten consecutive days in Celsius and store them into an array. The entire array should then be displayed. Next each temperature in the array should be converted to Fahrenheit and stored into a 2nd array. This entire array should then be displayed. The formula for converting Celsius to Fahrenheit is °F = (°C × 1.8) + 32. Finally, the number of cool, warm and hot days should be counted...
The sixth assignment involves writing a Python program to read in the temperatures for ten consecutive...
The sixth assignment involves writing a Python program to read in the temperatures for ten consecutive days in Celsius and store them into an array. The entire array should then be displayed. Next each temperature in the array should be converted to Fahrenheit and the entire array should be again be displayed. The formula for converting Celsius to Fahrenheit is °F = (°C × 1.8) + 32. Finally, the number of cool, warm and hot days should be counted and...
Q#3 Write a C++ program to read 10 temperatures in Celsius and to store the temperatures...
Q#3 Write a C++ program to read 10 temperatures in Celsius and to store the temperatures in an array of integers, then it should convert the temperatures to Fahrenheit and store the new values rounded to the nearest integer in another array . The program should display both temperatures in a table form.    F = 9/5 x C + 32 where F is temp in Fahrenheit and C temperature in Celsius
Write a JAVA program that displays a table of the Celsius temperatures and their Fahrenheit equivalents....
Write a JAVA program that displays a table of the Celsius temperatures and their Fahrenheit equivalents.  The formula for converting a temperature from Celsius to Fahrenheit is F = 9/ 5 C + 32 where F → Fahrenheit temperature C → Celsius temperature.  Allow the user to enter the range of temperatures in Celsius to be converted into Fahrenheit.  Your program must use a loop to display the values of the temperature conversions (see sample output). Sample...
Write a program that prints a custom conversion table from Celsius temperatures to Fahrenheit and Newton...
Write a program that prints a custom conversion table from Celsius temperatures to Fahrenheit and Newton (Links to an external site.) temperatures. The formula for the conversion from Celsius to Fahrenheit is : F=9/5*C+32 F is the Fahrenheit temperature, and C is the Celsius temperature. The formula for the conversion from Celsius to Newton is C = 100/33*N N is the Newton Temperature and C is the Celsius temperature Your C++ program should prompt the user for a lower value...
python fill in these questions--- 1. Examine target_map.txt. Write a Python program that will read this...
python fill in these questions--- 1. Examine target_map.txt. Write a Python program that will read this file, then compute and display the number of targets (#). Copy your Python program below: target_map.txt S##............................. ..#............................. ...######.........##########.... ........#..................#.... ........#.................#..... ........#####.......######...... ............#......#............ ............#.......#........... ............#.......#........... ......#######.......#........... ......#.............#........... ......#..............###........ ......#................#........ .......#...............#........ ........#...............#....... .........#.......#......#....... .........#..............#....... ............#...........#....... ............#...#.......#....... ............#...#........#...... ............#...#.........#..... ............#...#.........#..... ............#..........#........ ............#..............#.... ...##..#####....#..........#.... .#..............#...........#... .#..............#...........#... .#......#######............#.... .#.....#................#....... .......#................#....... ..####.........#.....#.......... ................######..........
Write a program in python to read from a file the names and grades of a...
Write a program in python to read from a file the names and grades of a class of students to calculate the class average, the maximum, and the minimum grades. The program should then write the names and grades on a new file identifying the students who passed and the students who failed. The program should consist of the following functions: a) Develop a getGrades() function that reads data from a file and stores it and returns it as a...
Write an assembly language program for 8085 microprocessor to read consecutive memory locations from 2000 to...
Write an assembly language program for 8085 microprocessor to read consecutive memory locations from 2000 to 2FFF & transfer to 4000 to 4FFF
Write a c++ program that does the following, read temperatures from a file name temp.txt into...
Write a c++ program that does the following, read temperatures from a file name temp.txt into an array, and after reading all the temperatures, output the following information: the average temperature, the minimum temperature, and the total number of temperatures read. Thank you!
Write a program in Python where you can swap only two consecutive elements. You have to...
Write a program in Python where you can swap only two consecutive elements. You have to show all steps to convert a string into another string (both strings will be anagrams of each other). E.g. GUM to MUG GUM GMU MGU MUG
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT