Question

Write this code on python 3 only.Suppose class Student represents information about students in a course. Each student has a name and a list of test scores. The Student class should allow the user to view a students name, view a test score at a given position, view the highest test score, view the average test score, and obtain a string representation of the students information. When a Student object is created, the user supplies the students name and the number of test scores. Each score is initially presumed to be 0. Complete the missing codes in the following program. class Student (object) Represents a student. def init (self name, number) All scores are initially 0. self name name self scores for count in xrange (number) self scores append (0) def getName (self) Returns the students name. your code here def setScore (self, i, score) Resets the ith score, counting from 1. your code here def gets core (self i) Returns the ith score, counting from 1. your code here def get Average (self) Returns the average score

0 0
Add a comment Improve this question Transcribed image text
Answer #1

def getName(self)
  self._name

def setScore(self,i,score):
   self._score[i-1]=score

def getScore(self, i):
   return self._score[i-1]

def getAverage(self):
lsum = sum(self._score)
  avg = lsum/len(self._score)
  return avg

def getHighestScore(self):
  return max(self._score)

def _str_(self)
  return "%s is a %s" % self._name

  

Add a comment
Know the answer?
Add Answer to:
Write this code on python 3 only. Suppose class Student represents information about students in a...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Write a class called Student. The specification for a Student is: Three Instance fields name -...

    Write a class called Student. The specification for a Student is: Three Instance fields name - a String of the student's full name totalQuizScore - double numQuizesTaken - int Constructor Default construtor that sets the instance fields to a default value Parameterized constructor that sets the name instance field to a parameter value and set the other instance fields to a default value. Methods setName - sets or changes the student name by taking in a parameter getName - returns...

  • 2. Create a class that represents a group of students called GroupOfStudents. Create another class Student...

    2. Create a class that represents a group of students called GroupOfStudents. Create another class Student that represents a typical student. The GroupOfStudents class has a list of students as well as the following methods: a. Group average b. Names of all the students whose test scores are below the group average, with an appropriate message c. Highest test score and the names of all the students having the highest score Create a separate test module where instances of the...

  • Must be in Python 3 exercise_2.py # Define the Student class class Student():    # Ini...

    Must be in Python 3 exercise_2.py # Define the Student class class Student():    # Initialize the object properties def __init__(self, id, name, mark): # TODO # Print the object as an string def __str__(self): return ' - {}, {}, {}'.format(self.id, self.name, self.mark) # Check if the mark of the input student is greater than the student object # The output is either True or False def is_greater_than(self, another_student): # TODO # Sort the student_list # The output is the sorted...

  • PYTHON The provided code in the ATM program is incomplete. Complete the run method of the...

    PYTHON The provided code in the ATM program is incomplete. Complete the run method of the ATM class. The program should display a message that the police will be called after a user has had three successive failures. The program should also shut down the bank when this happens. [comment]: <> (The ATM program allows a user an indefinite number of attempts to log in. Fix the program so that it displays a message that the police will be called...

  • I need code in java The Student class: CODE IN JAVA: Student.java file: public class Student...

    I need code in java The Student class: CODE IN JAVA: Student.java file: public class Student {    private String name;    private double gpa;    private int idNumber;    public Student() {        this.name = "";        this.gpa = 0;        this.idNumber = 0;    }    public Student(String name, double gpa, int idNumber) {        this.name = name;        this.gpa = gpa;        this.idNumber = idNumber;    }    public Student(Student s)...

  • Score Analysis creating a class named "Student" in python and use matplotlib package

    class students:       count=0       def __init__(self, name):           self.name = name           self.scores = []           students.count = students.count + 1       def enterScore(self):                     for i in range(4):                 m = int(input("Enter the marks of %s in %d subject: "%(self.name, i+1)))                self.scores.append(m)             def average(self):                 avg=sum(self.scores)/len(self.scores)                           return avg               def highestScore(self):                           return max(self.scores)         def display(self):                          print (self.name, "got ", self.scores)                      print("Average score is ",average(self))                          print("Highest Score among these courses is",higestScore(self))          name = input("Enter the name of Student:")  s = students(name)  s.enterScore()  s.average()  s.highestScore()  s.display()So I need to print two things, first one is to compute the average score of these courses and second one is to print out the course name with the highest score among these courses. Moreover I need to import matplotlib.pyplot as plt to show the score figure. I barely could pull the code this...

  • Python only please, thanks in advance. Type up the GeometricObject class (code given on the back...

    Python only please, thanks in advance. Type up the GeometricObject class (code given on the back of the paper). Name this file GeometricObjectClass and store it in the folder you made (xxlab14) 1. Design a class named Rectangle as a subclass of the GeometricObject class. Name the file RectangleClass and place it in the folder. 2. The Rectangle class contains Two float data fields named length and width A constructor that creates a rectangle with the specified fields with default...

  • Use C++ to create a class called Student, which represents the students of a university. A...

    Use C++ to create a class called Student, which represents the students of a university. A student is defined with the following attributes: id number (int), first name (string), last name (string), date of birth (string), address (string). and telephone (area code (int) and 7-digit telephone number(string). The member functions of the class Student must perform the following operations: Return the id numb Return the first name of the student Modify the first name of the student. . Return the...

  • C++ please use only easy code and stdio.h because im just a beginner Description Write the...

    C++ please use only easy code and stdio.h because im just a beginner Description Write the program that can manage the information of students as follows: S 1. This program has two phase; the input phase and the output phase. 2. In an input phase, a teacher inputs the information (name, score, and department) for each student. The total number of students who can be inputted should be defined as a NUM OF_STUDENT constant value. In this example, the value...

  • For Python 3.7+. TEST THE CODE WITH THE FOLLOWING GLOBAL CODE AFTER YOU'RE DONE: print('\nStart of...

    For Python 3.7+. TEST THE CODE WITH THE FOLLOWING GLOBAL CODE AFTER YOU'RE DONE: print('\nStart of A2 Student class demo ') s1 = Student('David Miller', major = 'Hist',enrolled = 'y', credits = 0, qpoints = 0) s2 = Student('Sonia Fillmore', major = 'Math',enrolled = 'y', credits = 90, qpoints = 315) s3 = Student('A. Einstein', major = 'Phys',enrolled = 'y', credits = 0, qpoints = 0)          s4 = Student('W. A. Mozart', major = 'Mus',enrolled = 'n', credits = 29, qpoints...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT