Question 1

First, create a random Numpy array of 20 rows and 5 columns and answer the following:

  • What is the average value of the second column
  • What is the average value of the first 5 rows of the third and fourth columns?
  • Create a copy of the array and change each element to '0' in the first 3 rows.
  • Change the value of each element in the array to 0.5 if the actual value is >=0.5

Question 2

Following are the average monthly temperature of Baltimore.

Min Max
Jan 30.5 48.2
Feb 38.4 50.3
March 48.1 58.7
April 56.8 61.9
May 65.2 70.5
June 75.9 82.4
July 83.6 88.2
Aug 86.5 93.1
Sep 75.3 86.7
Oct 64.6 77.5
Nov 58.1 67.2
Dec 45.4 53.6

  • Store the above information (use NumPy arrays)
  • Calculate the mean, highest and lowest temperature from the above array.
  • What is the average min and max temperatures in the last quarter (Oct-Dec) of the year.
  • Use a dot product operation to print the average temperature ((min+max)/2) of each month.

Question 3

Use NumPy random-number generation to create an array of 30 random grades in the range of 60 through 100, then reshape the result into a 10-by-3 array (which will actually represent the Midterm 1, Midterm 2 and Final grade of 10 students)

  • Calculate the average of all the grades.
  • Calculate the average of the grades in each column and each row.
  • Calculate the average of the grade of the first two and last two students.
  • Calculate the average of Midterm 1 and Midterm 2 grades of the first 5 students.
  • Increase each Midterm 1 and Midterm 2 grade scores by 10% and decrease the Final grade scores by 5% and print the result (Hint: use diagonal matric operation)
  • Write functions median and mode that use existing NumPy capabilities to determine the median (middle) and mode (most frequent) of the values in the array.
  • Test your function on three arrays of different shapes.
Academic Honesty!
It is not our intention to break the school's academic policy. Posted solutions are meant to be used as a reference and should not be submitted as is. We are not held liable for any misuse of the solutions. Please see the frequently asked questions page for further questions and inquiries.
Kindly complete the form. Please provide a valid email address and we will get back to you within 24 hours. Payment is through PayPal, Buy me a Coffee or Cryptocurrency. We are a nonprofit organization however we need funds to keep this organization operating and to be able to complete our research and development projects.