c. Test the Student class using the following: i. Define an object (name it evel
ID: 3780035 • Letter: C
Question
c. Test the Student class using the following: i. Define an object (name it evelyn) of Student class with name "Evelyn Samson" and ID 8398774. ii. Prompt user to enter 3 courses, one course at a time. Each time the user will enter the code, credits and grade. iii. Add the 3 courses to evelyn's dictionary of courses. iv. Delete the middle course from evelyn's dictionary of courses. v. Add another course to have a total of 3 courses in the dictionary vi. Compute evelyn's gpa. vii. Display evelyn's detailed information.Explanation / Answer
Source Code:
class Song(object):
def __init__(self, name, ide):
self.name = name
self.ide = ide
def cal(self):
val =0
code = {}
cdict = {}
credit=[]
grade=[]
for index in range(3):
print(" Enter for course",index+1)
c=input("Enter the code:")
code["code",index+1]=c
cr = input("Enter credits: ")
credit.append(cr)
g=input("Enter the grade: ")
grade.append(g)
print(code)
a = len(code)
a = round(a/2)
del code[('code',a)]
print(code)
code2 = {('code',3): '150' }
code.update(code2)
print(code)
for index in range(3):
if grade=='A':
val = val+4
elif grade=='B':
val = val+3
elif grade=='C':
val = val+2
gpa = val/3
print("Gpa is: ")
print(gpa)
calc = Song("Evelyn",8807)
calc.cal()
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.