Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write the main 7 _ student function, that takes two lists as parameters: the list of Student objects and the list of corresponding topic grades

Write the main7_student function, that takes two lists as parameters: the list of Student objects and the list of corresponding topic grades for those students. The function should print out the students with their GPA's. GPA values should be rounded to one decimal place.
Example usage:
>> stud =[Student('Cleo',21, 'Adelaide', 'Adelaide', 218918, False),
Student('Jake',20, 'Clovelly Park', 'Flinders', 218121, True),
Student('Callum',19, 'Blackwood', 'Flinders', 218958, True),
Student('David',24, 'Blackwood', 'Flinders', 218432, False),
Student('Claudia',26, 'Blackwood', 'Flinders', 218301, True),
Student('Mona',17, 'Royal Park', 'Adelaide', 218321, False),
Student('Clay',18, 'Clovelly Park', 'Flinders', 218900, True),
Student('Amy',21, 'Blackwood', 'Flinders', 218200, False),
Student('William',20, 'Clovelly Park', 'Adelaide', 218761, False),
Student('Luka',19, 'Royal Park', 'Adelaide', 218311, True)]
gpa =[('P','CR','CR'),('P','HD','CR'),
('HD','CR','DN','CR','WF'),('HD','CR','P','CR','WF'),
('HD','CR','P','F','CR'),('HD','CR','P','DN','DN'),
('HD','DN','P','CR','DN'),('HD','CR','P','CR','CR'),
('HD','CR','P','P','P'),('WF','CR','P','P')]
>> main7_student(stud,gpa)
output:
Name GPA
_____________
Cleo 4.7
Jake 5.3
Callum 4.9
David 4.5
Claudia 4.5
Mona 5.6
Clay 5.6
Amy 5.2
William 4.8
Luka 3.6
The definitions for Student and GPA are:
class Student:
'''An example class to hold basic attributes and methods associated with
a university student object'''
def __init__(self, name, age, address, uni, sn, empl):
self.name = name
self.address = address
self.age = age
self.uni = uni
self.sn = sn
def calculate_GPA(self, marks):
UNIT_VALUE =4.5
conv_table ={'HD':7,'DN':6,'CR':5,'P':4,'F':1.5,'WF':1.5}
num_of_marks = len(marks)
gpa_val =0
for ind, m in enumerate(marks):
if m in conv_table.keys():
gpa_val = gpa_val + conv_table[m]* UNIT_VALUE
else:
print('Error: mark at position %d is not acceptable' %ind)
return gpa_val/(num_of_marks*UNIT_VALUE) self.empl = empl

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Data Access Patterns Database Interactions In Object Oriented Applications

Authors: Clifton Nock

1st Edition

0321555627, 978-0321555625

More Books

Students also viewed these Databases questions

Question

Comment should this MNE have a global LGBT policy? Why/ why not?

Answered: 1 week ago