Answer to Question #111360 in Python for Abigail Dadian

Question #111360
Use the function written in the last lesson to calculate a student’s GPA. Ask them how many classes they are taking, then ask them to enter the grades for each class and if it is weighted.

Your program should then output the averaged GPA including the decimal place.

Your main program must call the function.
1
Expert's answer
2020-04-23T13:14:14-0400
def stGPA(student):
    a = 0
    for i in range(len(student)):
        a = a + int(student[i])
    return a / len(student)

print('How many students are in your group?')
nst = int(input())

print('How many classes You are taking?')
ncl = int(input())

students = []

for i in range(nst):
    grades = []
    for j in range(ncl):
        print('Enter grades for student',i+1)
        grades.append(input())
    students.append(grades)

for i in range(nst):
    print('student',i+1,'GPA =',stGPA(students[i]))

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS