Write a function called find_max that takes a two-dimensional
list as a parameter and returns the number of the row that sums to
the greatest value. For example, if you had the following list of
lists:
list = [[1, 2, 3], [2, 3, 3], [1, 3, 3]]
The first row would be 6, the second 8 and the third 7. The
function would, therefore, return 1.
You can assume the passed in list of lists has at least one row and
one column. You cannot assume that it is square.
def find_max(lst):
s = None
for x in lst:
tempSum = 0
for y in x:
tempSum += y
if(s == None):
s = tempSum
elif(s < tempSum):
s = tempSum
count = 0
for x in lst:
tempSum = 0
for y in x:
tempSum += y
if(s == tempSum):
count += 1
return count
#Testing
print(find_max([[1, 2, 3], [2, 3, 3], [1, 3, 3]]))

1
Write a function called find_max that takes a two-dimensional list as a parameter and returns the...
solve with python
Write a recursive function recStringWithLenCount() that takes a
one-dimensional list of strings as a parameter and returns the
count of strings that have at least the length of second parameter
passed into the function that are found in the list. Recall that
you can determine whether an item is a string by writing type(item)
== str. The only list functions you are allowed to use are len(),
indexing (lst[i] for an integer i), or slicing (lst[i:j] for...
Write a method that takes in a two-dimensional array of integers, do some calculation for each row in the two-dimensional array, and returns a one-dimensional array of sums for each row. Your code must work any array dimensions, including jagged arrays. The calculations are: • Sum of each row • Maximum value of each row • Minimum value of each row • Average of each row Here is an example an array passed and returns an array of sums for...
FOR PYTHON: Write a function findMinRow() that
takes a two-dimensional list of numbers as a parameter. It
returns the index of the minimum row in the list.
The minimum row is the row with the smallest sum of elements. If
the list has multiple rows that achieve the minimum value, the last
such row should be returned. If the list is empty the function
should return -1. The following shows several sample runs of the
function:
Python 3.4.1 Shell File...
1. Question: Write a function that takes a list L and returns a random sublist of size N of that list. Assume that the indexes must be in increasing order. That is, you cannot go backwards Example L [1, 2, 3, 4, 5] 5 The function should return one of these lists: [2, 3, 4] [2, 3, 5] [2, 4, 5] [3, 4, 5]
Write a method called averageVowels that takes an ArrayList of strings as a parameter and returns the average number of vowel characters (a, e, i, o, u) in all Strings in the list. If your method is passed an empty ArrayList, it should return 0.0.
Write a function called avg_max that takes a
list of lists (sublists may be empty) and return the average of the
largest item in each sublist as a float. If a sublist is empty, do
not consider it for the purposes of computing average. You may
assume that everything inside a non-empty sublist is a number. You
may assume that at least one sublist will be non-empty.
Write a function called avg max that takes a list of lists (sublists...
Write a recursive function bag_to_set that takes a list as a parameter and returns a new list in which the values that were in the old list appear only once in the new list (the order should be preserved). Sample data: Old list: [4, 5, 3, 4, 5, 2, 2, 4] New list: [4, 5, 3, 2] The function signature is: def bag_to_set(bag): """ ------------------------------------------------------- Copies elements of a bag to a set. Use: new_set = bag_to_set(bag) ------------------------------------------------------- Parameters: bag...
Write a function valid_integers(strings) that takes a list of strings as a parameter and returns a list of the integers that can be obtained by converting the strings to integers using an expression like int(string). Strings which cannot be converted in this way are ignored. Hint: the statement pass is a statement that does nothing when executed. For example: Test Result strings = ['123', '-39', '+45', 'x', 'COSC121', '123+', '12-3'] print(valid_integers(strings)) [123, -39, 45]
Please use Python 3, thank you~ Write a program that: Defines a function called find_item_in_grid, as described below. Calls the function find_item_in_grid and prints the result. The find_item_in_grid function should have one parameter, which it should assume is a list of lists (a 2D list). The function should ask the user for a row number and a column number. It should return (not print) the item in the 2D list at the row and column specified by the user. The...
Write a Scheme function DEL-LELEMENT that takes a list as a parameter and returns a list identical to the parameter except the last element has been deleted. For example, (DEL-LELEMENT '(8 2 3 7 6)) should return (8 2 3 7) *Please explain your code and submit the source code. Please test the function with the provided example and submit a screen shot of the testing result.