Question

Consider the magic matrix: A = np.array([[17, 24, 1, 8, 15],                          [23, 5, 7, 14, 16],...

Consider the magic matrix:

A = np.array([[17, 24, 1, 8, 15],

                         [23, 5, 7, 14, 16],

                         [ 4, 6, 13, 20, 22],

                         [10, 12, 19, 21, 3],

                         [11, 18, 25, 2, 9]])

The matrix A has 5 row sums (one for each row), 5 column sums (one for each column) and two diagonal sums. These 12 sums should all be exactly the same. Verify that they are the same by printing them and “seeing” that they are the same.

Homework Answers

Answer #1

Source Code:

import numpy as np
A=np.array([[17,24,1,8,15],
[23,5,7,14,16],
[4,6,13,20,22],
[10,12,19,21,3],
[11,18,25,2,9]])

# printing sum of each individual rows
for i in range(0,5):
print("Row",(i+1),"sum: ",end="")
summation=0
for j in range(0,5):
summation=summation+A[j][i]
print(summation)
  
# printing sum of each individual columns
for i in range(0,5):
print("Column",(i+1),"sum: ",end="")
summation=0
for j in range(0,5):
summation=summation+A[j][i]
print(summation)

# printing sum of individual each diagonal
summation=0
for i in range(0,5):
summation=summation+A[i][i]
print("Diagonal 1 sum: ",summation)
summation=0
for i in range(0,5):
summation=summation+A[i][4-i]
print("Diagonal 2 sum: ",summation)

Sample input and output:

Know the answer?
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
Similar Questions
Consider the following data: 25 24 18 20 21 18 16 20 23 17 15 13...
Consider the following data: 25 24 18 20 21 18 16 20 23 17 15 13 19 23 24 20 16 26 21 24 15 22 16 12 20 23 19 26 20 25 21 19 21 25 23 26 21 19 20 14 (a) Develop a frequency distribution using classes of 12-14, 15-17, 18-20, 21-23, and 24-26. Class Frequency   12-14   15-17   18-20   21-23   24-26     Total (b) Develop a relative frequency distribution and a percent frequency distribution using the classes...
Cork price: 16 10 15 10 17 11 14 13 11 14 11 16 18 16...
Cork price: 16 10 15 10 17 11 14 13 11 14 11 16 18 16 10 17 14 14 16 7 10 12 19 15 16 14 9 12 21 13 10 16 12 16 13 17 17 13 14 18 11 12 15 16 13 18 16 17 12 12 14 9 11 14 19 13 11 17 11 13 15 14 18 18 18 12 10 11 13 14 11 14 18 13 13 19 17 14...
Cork price: 16 10 15 10 17 11 14 13 11 14 11 16 18 16...
Cork price: 16 10 15 10 17 11 14 13 11 14 11 16 18 16 10 17 14 14 16 7 10 12 19 15 16 14 9 12 21 13 10 16 12 16 13 17 17 13 14 18 11 12 15 16 13 18 16 17 12 12 14 9 11 14 19 13 11 17 11 13 15 14 18 18 18 12 10 11 13 14 11 14 18 13 13 19 17 14...
Lessons Frequency 10-12 5 13-15 9 16-18 12 19-21 4 22-24 10 The mean for that...
Lessons Frequency 10-12 5 13-15 9 16-18 12 19-21 4 22-24 10 The mean for that distribution is: - 19.11 - 18.22 - 17.38 - 16.15 The mode of this distribution is: -23 -15 -17 -12
10, 15, 17, 18, 29, 15, 17, 18, 16, 24, 13, 38, 49, 29, 14, 25,...
10, 15, 17, 18, 29, 15, 17, 18, 16, 24, 13, 38, 49, 29, 14, 25, 21, 14, 35, 37, 38, 10, 19, 28, 17, 19, 24, 31, 32, 25, 26, 28, 19, 17, 24 Draw the following charts using the dataset above. Please write a sentence or two interpreting the result (35 pts): Histogram with five bins (be sure to use class boundaries) (10pts) Boxplot (15pts) Stem and Leaf Plot (10pts)
selling price in $ frequency 12- 15 8 16-19 23 20-23 17 24-27 18 28-31 8...
selling price in $ frequency 12- 15 8 16-19 23 20-23 17 24-27 18 28-31 8 32-35 4 36-39 2 1.calculate the average selling price 2.calculate the median 3. construct a histogram 4. Describe the data
6. Using the class data (see Blackboard file - "Class Survey Data - PSS-10 and GAS")...
6. Using the class data (see Blackboard file - "Class Survey Data - PSS-10 and GAS") calculate the correlation between the GAS – Goal disengagement and the GAS – Goal reengagement scores. Write the results in a statistical statement. 7. Using the class data calculate the correlation between the GAS – Goal disengagement and the PSS-10 scores. Write the results in a statistical statement. 8. Using the class data calculate the correlation between the GAS – Goal reengagement scores and...
A study was conducted to see if students’ writing skills continue to improve as the academic...
A study was conducted to see if students’ writing skills continue to improve as the academic year progresses. English 101 students were asked to write essays throughout the year in September, December, March and June. The scores were compared to see if there is any improvement in this one-year course. Was there a significant improvement? The appropriate test for this problem is: one-way ANOVA repeated measurements Student September December March June 1 17 23 21 24 2 25 21 21...
Assuming that the population standard deviation is unknown, calculate the 95% confidence interval of the population...
Assuming that the population standard deviation is unknown, calculate the 95% confidence interval of the population mean. The following is the data. Calculating Process should be shown by Excel (Formulas). What formulas in statistics are used? 7 21 23 24 18 16 2 19 11 6 3 13 17 9 5 12 13 17 4 14 15 25 12 24 22 14 14 20 15 11 26 17 21 11 4 13 16 14 13 14 25 23 9 15...
The table below shows average daily sales of Rice Krispies in the month of June in...
The table below shows average daily sales of Rice Krispies in the month of June in 74 Noodles & Company restaurants. Use the following data set and answer the questions 32 8 14 20 28 19 37 31 16 16 16 29 11 34 31 18 22 17 27 16 24 49 25 18 25 21 15 16 20 11 21 29 14 25 10 15  8 12 12 19 21 28 27 26 12 24 18 19 24 16...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT