Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

The purpose is to create a program that generates 3x3 matrices, in which it asks me for the values of each matrix and then shows

The purpose is to create a program that generates 3x3 matrices, in which it asks me for the values of each matrix and then shows the add, subtract, multiply or exit menu, but for some reason the script does not run. I need help. I am using python 3.7

a = [[],[],[]] b = [[],[],[]] def multiply(a,b,i,j): return a[i][0]*b[0][j]+a[i][1]*b[1][j]+a[i][2]*b[2][j] for i in range(3): for j in range(3): a[i][j] = int(input("Enter the value of the {} row {} column of the first matrix: ".format(i+1,j+1))) b[i][j] = int(input("Enter the value of the {} row {} column of the second matrix:".format(i+1,j+1))) while True: print("MENU:") print("1: Sum") print("2: Subtraction") print("3: Multiplication") print("4: Exit") op= int(input("Please write the operation you want to execute")) if op == 1: c = [[],[],[]] for i in range(3): for j in range(3): c[i][j] = a[i][j]+b[i][j] print("a+b=:") print("{} {} {}".format(c[0][0],c[0][1],c[0][2])) print("{} {} {}".format(c[1][0],c[1][1],c[1][2])) print("{} {} {}".format(c[2][0],c[2][1],c[2][2])) if op == 2: c = [[],[],[]] for i in range(3): for j in range(3): c[i][j] = a[i][j]-b[i][j] print("a-b=:") print("{} {} {}".format(c[0][0],c[0][1],c[0][2])) print("{} {} {}".format(c[1][0],c[1][1],c[1][2])) print("{} {} {}".format(c[2][0],c[2][1],c[2][2])) c = [[],[],[]] for i in range(3): for j in range(3): c[i][j] = b[i][j]-a[i][j] print("b-a=:") print("{} {} {}".format(c[0][0],c[0][1],c[0][2])) print("{} {} {}".format(c[1][0],c[1][1],c[1][2])) print("{} {} {}".format(c[2][0],c[2][1],c[2][2])) if select == 3: c = ([[],[],[]]) for i in range(3): for j in range(3):  c[i][j]=multiply(a,b,i,j) print("a*b=:") print("{} {} {}".format(c[0][0],c[0][1],c[0][2])) print("{} {} {}".format(c[1][0],c[1][1],c[1][2])) print("{} {} {}".format(c[2][0],c[2][1],c[2][2])) c = [[],[],[]] for i in range(3): for j in range(3): c[i][j]=multiply(b,a,i,j) print("b*a=:") print("{} {} {}".format(c[0][0],c[0][1],c[0][2])) print("{} {} {}".format(c[1][0],c[1][1],c[1][2])) print("{} {} {}".format(c[2][0],c[2][1],c[2][2])) if select == 4: break 

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Modern Dental Assisting

Authors: Doni Bird, Debbie Robinson

13th Edition

978-0323624855, 0323624855

Students also viewed these Programming questions

Question

What is the relevant price range for a product or service?

Answered: 1 week ago

Question

=+Suggest possible strategies that the firm might pursue.

Answered: 1 week ago