Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

from collections import namedtuple def makeStudent(student_list): Student = namedtuple('Student', ['name', 'major', 'year', 'id', 'gpa']) def makeStudent(studentlist): newStudent = Student(str(input()), input(), int(input()), int(input()), float(input())) studentlist.append(newStudent) def

from collections import namedtuple

def makeStudent(student_list): Student = namedtuple('Student', ['name', 'major', 'year', 'id', 'gpa']) def makeStudent(studentlist): newStudent = Student(str(input()), input(), int(input()), int(input()), float(input())) studentlist.append(newStudent)

def setGPA(student, val): student = student._replace(gpa = val) return student

def setMajor(student, val): student = student._replace(major = val) return student def setYear(student, val): student = student._replace(year = val) return student

def averageGPA(average_GPA): # gpa_list is a list of floats average_GPA = sum(student_gpa)/5 return average_GPA def getTopStudentGPA(Top_GPA): Top_GPA = max(student_gpa) return Top_GPA

if __name__ == "__main__": Student = namedtuple('Student', ['name', 'major', 'year', 'id', 'gpa']) K = Student('Kenneth', 'Computer Science', 6, 987654321, 3.8) M = Student('Maegan', 'Neuroscience', 4, 123456789, 3.4)

student_list = [] student_list.append(K) student_list.append(M) makeStudent(student_list) makeStudent(student_list) makeStudent(student_list) student_gpa = [] student_gpa.append(student_list[0].gpa) student_gpa.append(student_list[1].gpa) student_gpa.append(student_list[2].gpa) student_gpa.append(student_list[3].gpa) student_gpa.append(student_list[4].gpa)

print(student_list) print(student_list[1]) print(student_list[3])

averageGPA(student_gpa) getTopStudentGPA(student_gpa)

print(averageGPA(student_gpa)) print(getTopStudentGPA(student_gpa)) setGPA(M, 4.0) print(student_list[1].gpa)

why my function setGPA() is not working when it suppose to change Maegan's GPA to 4.0. And when I get the new GPA, am I suppose to get the new average using my function averageGPA.

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_2

Step: 3

blur-text-image_3

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

Visual Basic Net Database Programming

Authors: Rod Stephens

1st Edition

0789726815, 978-0789726810

More Books

Students also viewed these Databases questions