#source code:
def matrix_equal(matrix1,matrix2):
for i in range(len(matrix1)):
for j in range(len(matrix1[i])):
if(matrix1[i][j]!=matrix2[i][j]):
return False
return True
mat1=[['c','a','t'],['d','o','g'],['b','i','g']]
mat2=[['c','a','t'],['d','o','g'],['b','i','g']]
status=matrix_equal(mat1,mat2)
print("First matrix:")
for i in range(len(mat1)):
for j in range(len(mat1[i])):
print(mat1[i][j],end="\t")
print("\n")
print("Second matrix:")
for i in range(len(mat1)):
for j in range(len(mat1[i])):
print(mat2[i][j],end="\t")
print("\n")
print("Equal matrices:",status)
#output:
Implement the following function in the PyDev module functions.py and test it from a PyDev module...
Implement the following function in the PyDev module functions.py and test it from a PyDev module named t04.py: def print_matrix_char (matrix): وق في ال Prints the contents of a 2D list of strings in a formatted table. Prints row and column headings. Use: print_matrix_char (matrix) Parameters: matrix Returns None. a 2D list of strings (2D list) w Sample testing: Number of rows: 3 Number of columns: 4 0 1 2 3 i 0 C u r 1 Z 2 Y...
11. Implement the following function in the PyDev module functions.py and test it from a PyDev module named t11.py: def find_word_vertical(matrix, word): Look for word in each column of the given matrix of characters. Returns a list of indexes of all column that are equal to word. Returns an empty list if no column is equal to word. Use: cols - find_word_vertical(matrix, word) Parameters: matrix - the matrix of characters (2D list of str) word - the word to search...
Using Python Programming Language: 4. Implement the following function in the PyDev module functions.py and test it from a PyDev module named t04.py: def print_matrix_char(matrix): Prints the contents of a 2D list of strings in a formatted table. Prints row and column headings. Use: print_matrix_char (matrix) Parameters: matrix - a 2D list of strings (2D list) Returns: None. Sample testing: Number of rows: 3 Number of columns: 4 0 1 2 3 i 0 с u r 1 с у...
Question A matrix of dimensions m × n (an m-by-n matrix) is an ordered collection of m × n elements. which are called eernents (or components). The elements of an (m × n)-dimensional matrix A are denoted as a,, where 1im and1 S, symbolically, written as, A-a(1,1) S (i.j) S(m, ). Written in the familiar notation: 01,1 am Gm,n A3×3matrix The horizontal and vertical lines of entries in a matrix are called rows and columns, respectively A matrix with the...
Use your Food class, utilities code, and sample data from Lab 1 to complete the following Tasks. def average_calories(foods): """ ------------------------------------------------------- Determines the average calories in a list of foods. foods is unchanged. Use: avg = average_calories(foods) ------------------------------------------------------- Parameters: foods - a list of Food objects (list of Food) Returns: avg - average calories in all Food objects of foods (int) ------------------------------------------------------- """ your code here is the...
Help with solution using Python test using def riffle_generator(seed): random.seed(seed) for i in range(1000): n = random.randint(0, 100) items = [random.randint(0, 10**6) for j in range(2 * n)] yield (items, True) yield (items, False) Riffle def riffle(items, out True): Given a list of items that is guaranteed to contain an even number of elements (note that the integer zero is an even number), create and return a list produced by performing a perfect riffle to the items by interleaving the...
Write a module of utility functions called util.py for manipulating 2-dimensional arrays of size 4x4. (These functions will be used in Question 3.) The functions you need to write are as follows: def create_grid(grid): """create a 4x4 array of zeroes within grid""" def print_grid (grid): """print out a 4x4 grid in 5-width columns within a box""" def check_lost (grid): """return True if there are no 0 values and there are no adjacent values that are equal; otherwise False""" def check_won...
Hi, can someone please help me implement the transpose, multiply(Matrix b), multiply(Matrix m, int threads), and equals(Object in) methods? (This is Java) I really need help so please don't just refund the question. public class Matrix {1 public int[] [] matrix; 1 int[] [] trans; 1 public int x, y; 1 private boolean transposed; 1 1 public Matrix(int x, int y){1 matrix = new int[x][y1;1 this.x = x; this.y = y; 1 } 1 9 /*1 * This method takes...
In this question, you will test, using a backtracking algorithm, if a mouse can escape from a rectangular maze. To ensure consistency of design, start your solution with maze_start.c. The backtracking algorithm helps the mouse by systematically trying all the routes through the maze until it either finds the escape hatch or exhausts all possible routes (and concludes that the mouse is trapped in the maze). If the backtracking algorithm finds a dead end, it retraces its path until it...
Encoding and Decoding PPM image 3 & 4 are parts of question 2 Code for a09q1: We were unable to transcribe this image3 Encoding an Image in a09q2.py In the next four sections, you will no longer write class methods but rather functions. In each of the next four parts, you should be importing the PPM class from a09q1.py to use with the command from a09q1 import PPM Note that this is similar to how the check module was imported...