Question: Can someone solve these for me using only len(), range(), append(), and del keyword when needed as the directions state? No list comprehension, slicing, or

Can someone solve these for me using only len(), range(), append(), and del keyword when needed as the directions state? No list comprehension, slicing, or importing modules. Please and thank you.

def transpose_matrix(mat) Creates and returns a new matrix that is the transpose of mat https://en.wikipedia.org/wiki/Transpose mat is a nested list (e.g. [[1,2,3], [4,5,6]] and is guaranteed to have a rectangular shape and more than one elements Youre not allowed to use slicing, or import modules, or use the list comprehension syntax The only functions youre allowed to use are: len() , range() , append() Examples: transpose_matrix([[1,2,3], [4,5,6]]) [[1,4], [2,5], [3,6]] transpose_matrix([[1,2],[3,4],[5,6]]) [[1,3,5], [2,4,6]]

def diagonal_matrix(mat) Converts a square matrix mat into a lower diagonal matrix https://en.wikipedia.org/wiki/Triangular_matrix After the conversion the values on the diagonal will be the sum of the deleted elements in the respective row Return value is None. Variable mat is directly modified in memory mat is a nested list (e.g. [[1,2,3], [4,5,6], [7,8,9]] and is guaranteed to have a square shape of size at least 2x2 Youre not allowed to use slicing, or import modules, or use the list comprehension syntax The only functions youre allowed to use are: len() , range() and the del keyword Examples: diagonal_matrix([[1,2,3], [4,5,6], [7,8,9]]) [[6], [4, 11], [7, 8, 9]] diagonal_matrix([[1,2],[3,4]]) [[3], [3,4]]

def reduce_matrix(mat) Reduces the size of matrix mat in half, in both dimensions, by merging adjacent elements The new values of the matrix are the average of the respective merged elements Return value is None. Variable mat is directly modified in memory mat is a nested list (e.g. [[1,2,3,4], [5,6,7,8]] and is guaranteed to be non-empty and have a rectangular shape. Both dimensions are even numbers Youre not allowed to use slicing, or import modules, or use the list comprehension syntax The only functions youre allowed to use are: len() , range() and the del keyword Examples: reduce_matrix([[1,2],[3,4]]) '[[2.5]]' reduce_matrix([[1,2,3,4],[5,6,7,8],[9,8,7,6],[5,4,3,2]]) '[[3.5,5.5],[6.5,4.5]]'

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!