This is python: #Imagine you're writing a program to calculate the class #average from a gradebook. The...

70.2K

Verified Solution

Question

Programming

This is python:

#Imagine you're writing a program to calculate the class
#average from a gradebook. The gradebook is a list of
#instances of the Student object.
#
#You don't know everything that's inside the Student object,
#but you know that it has a method called get_grade().
#get_grade() will return the average for the student
#represented by a given instance of Student.
#
#You don't know if get_grade() is stored in memory or if
#it's calculated when it's needed, but you don't need to.
#All you need to know is that the class Student has a method
#get_grade() that returns an integer representing the
#student's numeric grade.
#
#Write a function called class_average. class_average()
#should take as input a list of instances of Student, and it
#should return as output the average grade of those
#students, as calculated via their get_grade() method.
#Remember, average is the sum of all their individual
#grades, divided by the number of students.
#
#Hint: You do NOT need to write the Student class to
#complete this problem. You may if you want to in order to
#run and test your code, but when you submit your code for
#grading, we will test it with our Student class. Don't let
#this throw you off: throughout this course, you've been
#using lots of classes without knowing how they work: you
#don't know how the String class works, but you know what
#its upper() method does. You do not need to know how the
#Student class works to use its get_grade() method.


#Write your function here!

#If you want to write a Student class to test your code,
#you could below, and then add your own test cases below
#that. The only requirement you would need to meet is that
#your Student class would need to have a get_grade()
#method that returns an integer (in addition to any other
#usual requirements for classes).

Answer & Explanation Solved by verified expert
4.1 Ratings (674 Votes)
Python Code forthe provided problem statement Python program to calculate the Average grades of eachstudent as well as the average of class grades student classclass Student def initself roll name lst constructor selfname name name selfroll roll rollNumber selflst lst list ofmarks this class method will calculate the average marksof current student    See Answer
Get Answers to Unlimited Questions

Join us to gain access to millions of questions and expert answers. Enjoy exclusive benefits tailored just for you!

Membership Benefits:
  • Unlimited Question Access with detailed Answers
  • Zin AI - 3 Million Words
  • 10 Dall-E 3 Images
  • 20 Plot Generations
  • Conversation with Dialogue Memory
  • No Ads, Ever!
  • Access to Our Best AI Platform: Flex AI - Your personal assistant for all your inquiries!
Become a Member

Other questions asked by students