Question
Please Help!!!! python project I can not get right average calculation. also how I can type any key to add student, I want to use
Please Help!!!! python project
I can not get right average calculation. also how I can type any key to add student, I want to use only c or C to continue.........
# student class class Student: # capturing the student info def __init__(self, id, name, grade1, grade2, grade3, grade4): self.id=id self.name=name self.grades=[grade1, grade2, grade3, grade4] # calculates the average of grade def getAverage(self): return (self.grades[0]+self.grades[0]+self.grades[0]+self.grades[0])/4.0 # gives string representation of student object def __str__(self): return "Student: \tId: "+self.id+" \tname: "+self.name+" \tAverage: "+str(self.getAverage())+" "
def process(): # list stores list of student objects List=[] while True: # enter choice to continue or quit choice=input("Enter a for add student/ Enter c for calcilate grade: ") if choice=="c": break # take info of student and add to list name=input("Enter students name: ") id=input("Enter students id: ") grade1=int(input("Enter grade1: ")) grade2 = int(input("Enter grade2: ")) grade3= int(input("Enter grade3: ")) grade4 = int(input("Enter grade4: ")) student=Student(id, name, grade1, grade2, grade3, grade4) List.append(student) # iterate over student list and print them for std in List: print(std)
process()
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started