Question

Write a program that uses a two-dimensional array to store the highest and lowest temperatures for each month of the year. Th

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Source Code::-

import numpy as np

#importing numpy which will give process the multidimensional list.

def getData():

#getData method will accepts 12 month of highest and lowest temperatures.

temp = []

for i in range(2):

#Storing temperatures from 1 to 12 month

low_high = []

low_temp = raw_input("Enter %s month Lowest temperatures::"%int(i+1))

#Storing lowest temperatures

high_temp = raw_input("Enter %s month Highest temperatures::"%int(i+1))

#Storing lowest temperatures

low_high.append(int(low_temp))

low_high.append(int(high_temp))

temp.append(low_high) #Storing temperatures in multidimensional list

print(temp)

avg_high_temp(temp) #calling avg_high_temp

avg_low_temp(temp) #calling low_high_temp

highest_temp(temp) #calling highest_temp

lowest_temp(temp) #lowest_temp

def avg_high_temp(temp):

#It will return Average Highest temperatures.

avg_high = []

for arr in temp:

avg_high.append((arr[1]))

print("Average Highest temperatures of the year::%s"%(float(sum(avg_high))/len(avg_high)))

def avg_low_temp(temp):

#It will return Average Lowest temperatures.

avg_low = []

for arr in temp:

avg_low.append((arr[0]))

print("Average Lowest temperatures of the year::%s"%(float(sum(avg_low))/len(avg_low)))

def highest_temp(temp):

#It will return highest temperatures of the year

print("Highest temperatures of the year::%s"%np.amax(temp))

def lowest_temp(temp):

#It will return Lowest temperatures of the year

print("Lowest temperatures of the year::%s"%np.amin(temp))

  

getData() #Calling getData method which take data from user.

Output::-

Enter 1 month Lowest temperatures::5

Enter 1 month Highest temperatures::25

Enter 2 month Lowest temperatures::6

Enter 2 month Highest temperatures::26

Enter 3 month Lowest temperatures::7

Enter 3 month Highest temperatures::27

Enter 4 month Lowest temperatures::8

Enter 4 month Highest temperatures::28

Enter 5 month Lowest temperatures::9

Enter 5 month Highest temperatures::29

Enter 6 month Lowest temperatures::10

Enter 6 month Highest temperatures::30

Enter 7 month Lowest temperatures::11

Enter 7 month Highest temperatures::31

Enter 8 month Lowest temperatures::12

Enter 8 month Highest temperatures::32

Enter 9 month Lowest temperatures::13

Enter 9 month Highest temperatures::33

Enter 10 month Lowest temperatures::14

Enter 10 month Highest temperatures::34

Enter 11 month Lowest temperatures::15

Enter 11 month Highest temperatures::35

Enter 12 month Lowest temperatures::16

Enter 12 month Highest temperatures::36

[[5, 25], [6, 26], [7, 27], [8, 28], [9, 29], [10, 30], [11, 31], [12, 32], [13, 33], [14, 34], [15, 35], [16, 36]]

Average Highest temperatures of the year::30.5

Average Lowest temperatures of the year::10.5

Highest temperatures of the year::36

Lowest temperatures of the year::5

Screen Shot::-

import numpy as np #importing numpy which will give process the multidimensional list def getData(): #getData method will accdef highest_temp (temp) #It will return highest temperatures of the year print( Highest temperatures of the year:5%s%np.ama

Add a comment
Know the answer?
Add Answer to:
Write a program that uses a two-dimensional array to store the highest and lowest temperatures for each month of the year. The program should output the average high, average low, and the highest and...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Write a program that uses a two-dimensional array to store the highest and lowest temperatures for...

    Write a program that uses a two-dimensional array to store the highest and lowest temperatures for each month of the year. You should also have a parallel array to store the names of the 12 months. The program should read the Month's names, and the temperatures from a given input file called temperature.txt. The program should output the highest and lowest temperatures for the year, and the months that correspond to those temperatures. The program must use the following functions:...

  • I need this asap. C++ please A A Ap Aa Consolas 14 AaBbCcDd AaBbCcDd AaBbCc Editing...

    I need this asap. C++ please A A Ap Aa Consolas 14 AaBbCcDd AaBbCcDd AaBbCc Editing ste 1 No Spac.. Heading 1 В I 1 Normal x A U A v ab х. Dictate ipboard Font Paragraph Styles Voice Write a program that uses a two-dimensional array to store the highest and lowest temperatures for each month of the year. The program should output the average high, average low, and the highest and lowest temperatures for the year. Your program...

  • Write a C++ program that demonstrates use of programmer-defined data structures (structs), an array of structs, passing...

    Write a C++ program that demonstrates use of programmer-defined data structures (structs), an array of structs, passing an array of structs to a function, and returning a struct as the value of a function. A function in the program should read several rows of data from a text file. (The data file should accompany this assignment.) Each row of the file contains a month name, a high temperature, and a low temperature. The main program should call another function which...

  • java pseudocode and source code help? Write a program that uses an array of high temperatures...

    java pseudocode and source code help? Write a program that uses an array of high temperatures for your hometown from last week (Sunday - Saturday). Write methods to calculate and return the lowest high temperature (minimum) and a method to calculate and return the highest high temperature (maximum) in the array. You must write YOUR ORIGINAL methods for minimum and maximum. You MAY NOT use Math class methods or other library methods. Write an additional method that accepts the array...

  • Write a program that dynamically allocates an array in the freestore large enough to hold a...

    Write a program that dynamically allocates an array in the freestore large enough to hold a user defined number of test scores as doubles. Once all the scores are entered, the array should be passed to a function that finds the highest score. Another function the array should be passed to a function that finds the lowest score. Another function should be called that calculates the average score. The program should show the highest, lowest and average scores. Must use...

  • Write a program that dynamically allocates an array in the freestore large enough to hold a...

    Write a program that dynamically allocates an array in the freestore large enough to hold a user defined number of test scores as doubles. Once all the scores are entered, the array should be passed to a function that finds the highest score. Another function the array should be passed to a function that finds the lowest score. Another function should be called that calculates the average score. The program should show the highest, lowest and average scores. Must use...

  • IN JAVA Write a program that uses a two-dimensional array to store daily minutes walked and...

    IN JAVA Write a program that uses a two-dimensional array to store daily minutes walked and carb intake for a week. Prompt the user for 7 days of minutes walked and carb intake; store in the array.   Write a sort ( your choice which sort ) to report out the sorted minute values -lowest to highest. Write another to report out the sorted carb intake - highest to lowest. These methods MUST be your original code.   Your program should output...

  • Write a program that uses a two-dimensional array to store daily minutes walked and protein intake...

    Write a program that uses a two-dimensional array to store daily minutes walked and protein intake for a week. Prompt the user for 7 days of minutes exercise and protein intake; store in the array. Write a bubble sort to report out the sorted minutes walked values -lowest to highest. Write another to report out the sorted protein intake - highest to lowest. Your program should output all the values stored in the array and then output the 2 sorted...

  • Write a program that demonstrates use of programmer - defined data structures. Please provide code! Thank...

    Write a program that demonstrates use of programmer - defined data structures. Please provide code! Thank you. Here are the temps given: January 47 36 February 51 37 March 57 39 April 62 43 May 69 48 June 73 52 July 81 56 August 83 57 September 81 52 October 64 46 November 52 41 December 45 35 Janual line Iranin Note: This program is similar to another recently assigned program, except that it uses struct and an array of...

  • Write a simple polling program that allows users to rate 5 issues from 1 (low importance)...

    Write a simple polling program that allows users to rate 5 issues from 1 (low importance) to 10 (high importance). Use a one dimensional array of type String to store the five causes. Prompt for the number to be polled. Use a 5X(numPolled) int array to store the results of the survey, but please prompt for the file name. When you run the program ask a user rate each issue. The five issues are Environment, War and Peace, Economy, Education,...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT