Question: Goals: In Python Developing problem-solving skills, using 2-D lists and functions Problem: You have been asked to write a program that will aid a high

Goals: In Python Developing problem-solving skills, using 2-D lists and functions Problem: You have been asked to write a program that will aid a high school teacher with grades in the course. The students have a 6-digit numeric student number, and scores from 10 assignments. Your program should contain the following functions. One function should prompt the user to enter the 6-digit student number and the 10 assignment scores (the assignment grades should be entered as floating point numbers) for each student and store this information into a 2-d list. The information for each student should be contained in a separate row. The number of students in the class should be passed to this function as an input parameter. (Hint: review and modify the function Make2Dlist given in the file 2dlistexamplesdemo.py given in the module for week 9) One function should output the 2-D list in a formatted manner. This function should accept the 2-D list as an input parameter. Then using formatting techniques given on pages 68 through 73 of your textbook output the 2-D list using field width of 8 for the student numbers, and a field width 7 for each of the assignment grades. The assignment grades should be displayed with 2 decimal places. This function should not return anything. One function should accept the 2-D list and create a 1-D list containing the minimum value for each assignment and another 1-D list containing the maximum value for each assignment. Both these 1-D lists should be returned to the function call. Below is some code that is an example. You should modify it appropriately # using columns in 2D arrays twoDlist = [['Sam', 45, 76, 88, 99, 72], \ ["Ally",66,99,84, 82, 96], \ ['John', 58, 78, 90, 93, 70], \ ['Marie', 77, 73, 85, 88, 92], \ ['Bob', 81, 83, 85, 91, 88], \ ['Grace', 92, 95,87, 82, 90]] # find minimum of each numeric column mincolumns = [] for colnumb in range(1,6): minval = twoDlist[0][colnumb] Programming Project 4 2 CMPSC 101-Spring 2018 for ri in range(1,len(twoDlist)): if twoDlist[ri][colnumb] < minval: minval = twoDlist[ri][colnumb] mincolumns.append(minval) Finally, your program should contain a main function (yes call it main) that will prompt the user to enter the number of students, call the function to fill the 2-D list, call the function to display the 2-D list, call the function to determine the maximum and minimum scores for each assignment, and print the 1-D lists containing the maximum and minimum scores. The output should look similar to that given below. The maximum scores for each assignment are: [99.78, 97.0, 95.7, 99.9, 98.56, 90.2, 97.47, 98.14, 93.1, 98.5] The minimum scores for each assignment are: [67.8, 45.26, 55.12, 50.3, 46.2, 56.1, 47.98, 38.99, 49.62, 40.5] For 10 points of extra credit: Create another function that will accept the 2-D list and create a 1-D list containing the total score for each student and return the 1-D list containing the total to main. This function should be called from main and main should display the 1-D list of totals.

This is the hint:

Page

1 of 2 # Program to demonstrate using functions for the output and input of

# 2-Dimensional lists

# input: values for 2-dimensional list using a function

# output: the values in the list using a function

# processing: using nested loops

def main():

Temps =

[[48.9, 42.7, 45.5, 55.1, 68.9, 74.7, 70.1, 60.7],

[51.8, 48.5, 48.9, 50.8, 56.6, 62.5, 58.3, 45.4],

[40.5, 40.3, 41.5, 50.4, 54.3, 61.8, 60.0, 52.7],

[50.9, 48.9, 47.3, 53.6, 60.2, 65.7, 64.6, 54.1],

[48.7, 45.2, 44.8, 52.8, 60.4, 68.4, 60.2, 49.2],

[45.4, 44.9, 48.9, 57.9, 59.3, 61.5, 50.7, 45.3],

[42.9, 45.6, 47.8, 48.9, 50.3, 51.9, 50.8, 49.9]]

#Print2Dlist(Temps)

listc = Make2DList()

Print2Dlist(listc)

# Function to output the elements of a 2-dimensional list

# input: a 2-D list

# output: The function does not return anthing to the function call, but outputs

# the list to the screen

# processing: Determine the number of rows in the 2-D list using the len function.

# Create a nested loop in which the outer loop controls which row is

# being printed and the inner loop will output the elements of that

# row

def Print2Dlist(list2d):

numbrows = len(list2d)

for rowindex in range(numbrows):

numbcolumns = len(list2d[rowindex])

for columnindex in range(numbcolumns):

print(list2d[rowindex][columnindex],end = '\t')

print('') # for new row

# Function to allow the user to enter the elements for a 2-D list assuming that

# that the user knows how many rows and columns the list should have and that

# each row has the same number of elements

# input: nothing will be passed to the function, but user will be prompted to

# enter the elements of the list

# output: the 2-D will be returned to the function call

# processing: Prompt the user to enter the number of rows and columns for the list.

# Create an empty list. Use an outer loop to create an empty list

# for a row. Inner loop will append values to that row.

Append the

# the row to the empty list

def Make2DList():

numbr = int(input('Enter the number of rows for the 2-D list. '))

numbc = int(input('Enter the number of columns for the 2-D list. '))

lista2 = []

for rowi in range(numbr):

eachrow = []

for columnj in range(numbc):

val = eval(input('Enter a numeric value the element in row ' +str(rowi + 1) + ' and column ' + str(columnj + 1) +'. '))

eachrow.append(val)

lista2.append(eachrow)

return lista2

main()

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!