Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

new to python help with it i am using python 3, if you can add a screenshot it w

ID: 3717593 • Letter: N

Question

new to python help with it i am using python 3, if you can add a screenshot it would help alot

** 12.2 (The Location class) Design a class named Location for locating a maximal value and its location in a two-dimensional list. The class contains the public data fields row, column, and maxValue that store the maximal value and its indexes in a two-dimensional list, with row and column as int types and maxValue as a float type Write the following method that returns the location of the largest element in a two-dimensional list. def Location locateLargest(a): The return value is an instance of Location. Write a test program that prompts the user to enter a two-dimensional list and displays the location of the largest ele- ment in the list. Here is a sample run: Enter the number of rows and columns in the list: 3, 4 Enter Enter row 0: 23.5 35 2 10 Enter Enter row 1: 4.5 3 45 3.5 Endr Enter row 2: 35 44 5.5 12.6 Enter The location of the largest element is 45 at (1, 2)

Explanation / Answer

Hi, Please find my implementation in Python.

import sys;

#Class that holds max value and its index positions
class Location:
   row = 0;
   column = 0;
   maxValue = 0.0;
  
   #Constructor that initializes data values
   def __init__(self, row, column, maxValue):
       self.row = row;
       self.column = column;
       self.maxValue = maxValue;

#Function that finds largest element and returns its position
def locateLargest(a):
   max = 0.0;
   r = 0;
   c = 0;
  
   #Looping through multidimensional list
   i = 0;
   for row in a:
       j = 0;
       for col in row:
           if col > max:
               max = col;
               r = i;
               c = j;
           j = j+1;
       i = i+1;
  
   #Creating instance of the object
   loc = Location(r, c, max);
  
   #Return instance
   return loc;
          
#Main Function          
def main():
   #Reading rows and columns
   row,column = input(" Enter number of rows and columns in the list: ").split(',')
  
   row = int(row);
   column = int(column);
  
   #Initializing multidimensional list with zeros
   data = [[0 for i in range(0,column)] for j in range(0,row)];
  
   #Reading data from user
   for i in range(0,row):
       data[i] = input(" Enter row " + str(i) + ": ").split();
       data[i] = [float(k) for k in data[i]];
  
   #Calling function that returns instance of largest element
   loc = locateLargest(data);
  
   #Printing values
   print(" Location of the largest element is " + str(loc.maxValue) + " at: (" + str(loc.row) + ", " + str(loc.column) + ")");

if __name__ == "__main__":
main();