Question

need a code in python that takes 3 array matrix and prints them with your inputs...

need a code in python that takes 3 array matrix and prints them with your inputs entered please

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

Screenshot of the code used:

The output obtained:

The code used:

print("Enter the dimensions of the matrix")  # asking for the dimension of the matrix, to take as input.
row = int(input("Enter the number or rows: "))  # taking the input of the number or rows in the matrix.
col = int(input("Enter the number of columns: "))  # taking the input of columns and also converting it to integer.

matrix = list()  # this will store our elements.
for i in range(row):   # taking the input for the matrix.
    print("Enter the element of row"+str(i), ":", end=" ")
    # Here we have first taking the input using input() and we split the input using the white space
    # splitting is done using the split() function, now after this we convert individual number which are
    # is string form to integer this is done by map() function and finally we convert the whole thing to a
    # list and append it to our matrix, so basically matrix is nothing but a list or list.
    matrix.append(list(map(int, input().split())))


print("The matrix entered as input is:")     # Next, we print our matrix, using nested for loop.
for i in range(row):
    for j in range(col):
        print(matrix[i][j], end=" ")
    print()

I hope you like the solution. In case of any doubts regarding the solution feel free to ask it in the comment section. If you like the solution please give a thumbs up.

Add a comment
Know the answer?
Add Answer to:
need a code in python that takes 3 array matrix and prints them with your inputs...
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
  • SOLVE IN PYTHON: Exercise #2: Develop a program (name it LocateLargestElement) that prints out the location...

    SOLVE IN PYTHON: Exercise #2: Develop a program (name it LocateLargestElement) that prints out the location of the first largest value in a two-dimensional array. The largest values may appear more than once in the array. The program defines method locateLargest() that takes a two-dimensional array of integers and returns the location (row index and column index) of the first largest value as a single-dimensional array. The program main method prompts the user to enter a 3-by-4 matrix, prints out...

  • This needs to be in python, however, I am having trouble with the code. Is there...

    This needs to be in python, however, I am having trouble with the code. Is there any way to use the code that I already have under the main method? If so, what would be the rest of the code to finish it? #Create main method def main(): #Create empty list list=[] #Display to screen print("Please enter a 3 x 4 array:") #Create loop for rows and have each entered number added to list for i in range(3): list.append([int(x) for...

  • // Program takes 5 numbers from a user (from console), stores them into an // array,...

    // Program takes 5 numbers from a user (from console), stores them into an // array, and then prints them to the screen (on the same line). // Add code to complete this program. You only need to add code where indicated // by "ADD HERE". #include <iostream> using namespace std; int main() { const int SIZE = 5; // size of array // ADD HERE - create an array of integers that will hold 5 integers. cout << "please...

  • 1.Write code for a Java method, printArray, that takes an int array as parameter and prints...

    1.Write code for a Java method, printArray, that takes an int array as parameter and prints it out, one element per line. public static void printArray (int[] values){ Methods that do NOT return a result have “void” as return type. Notice how an array parameter type is passed, int [] }// end printArray 2.Write code for a Java method that takes in as input parameter an integer number, say num, and returns a double array of size num with all...

  • Write a python code that takes in an number 0-9 and prints out the word of...

    Write a python code that takes in an number 0-9 and prints out the word of the number. For example 1 would print out one. Below is the skeleton of the code that needs to be filled in. def num2string(num): """ Takes as input a number, num, and returns the corresponding name as a string. Examples: num2string(0) returns "zero", num2string(1)returns "one" Assumes that input is an integer ranging from 0 to 9 """ numString = "" ################################### ### FILL IN...

  • Jupyter code (PYTHON) True error Write a function called trueError that takes the following inputs: •...

    Jupyter code (PYTHON) True error Write a function called trueError that takes the following inputs: • X, the new value • Xtrue, the previous value And returns the following output: • error, the calculated relative error The formula for the relative error is shown below: errue = 11100% In (): def trueError(x,xtrue): # YOUR CODE HERE raise Not ImplementedError() In (): # You can call and test your function here # YOUR CODE HERE raise Not ImplementedError()

  • Code in C++ please! Write a function that takes an array of integers as an input...

    Code in C++ please! Write a function that takes an array of integers as an input parameter (the address of the first value of the array). It returns nothing. It prints out the array as a single line, with commas between each number, and when the array is finished being printed, it prints an endl; so that we flush the buffer and move to a new line. (I’m having you write this function because you’ll be wanting to print out...

  • Please write a python function for : greedy: This function takes two inputs: one a graph,...

    Please write a python function for : greedy: This function takes two inputs: one a graph, and the other an ordering of the vertices as a list, and returns the proper vertex-coloring produced by the greedy algorithm over the ordering in the list. Examples: greedy({"A" : ["B", "C"], "B" : ["A"], "C" : ["A"]},[“A”, “B”, “C”]) should return {“A” : 1, “B” : 2, "C" : 2} greedy({“A” : ["B"], "B" : [“A”, “C”],"C" : [“B”, “D”), “D" : ["C"]},[“A”,...

  • I need this code in C++. Should be able to read from a file as stated...

    I need this code in C++. Should be able to read from a file as stated in the directions Exercise #1: Develop a program that prints out the sum of each column of a two-dimensional array The program defines method sumColumn takes a two-dimensional array of integers and returns a single dimensional array that stores the sum of columns of the passed array. The program main method prompts the user to enter a 3-by-4 array, prints out the array, and...

  • 1) Translate the following equation into a Python assignment statement 2) Write Python code that prints...

    1) Translate the following equation into a Python assignment statement 2) Write Python code that prints PLUS, MINUS, O ZERO, depending on the value stored in a variable named N. 3) What is printed by: 3 - 1 while 5: while 10 Print ) Page 1 of 9 4) Write a Python while loop that reads in integers until the user enters a negative number, then prints the sum of the numbers. 1-2 of 9 4) Write a Python while...

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