subject

This project assumes that you have completed Project 1. Place several Student objects into a list and shuffle it. Then run the sort method with this list and display all of the students’ information. Print to the console the unsorted list first of all students followed by the sorted list of all students """
File: student. py
Project 9.2
Resources to manage a student's name and test scores.
Includes methods for comparisons and testing for equality.
Tests the class by putting students into random order in a list
and then sorting them.
"""

class Student(object):
"""Represents a student."""

def __init__(self, name, number):
"""All scores are initially 0."""
self. name = name
self. scores = []
for count in range(number):
self. scores. append(0)

def getName(self):
"""Returns the student's name."""
return self. name

def setScore(self, i, score):
"""Resets the ith score, counting from 1."""
self. scores[i - 1] = score

def getScore(self, i):
"""Returns the ith score, counting from 1."""
return self. scores[i - 1]

def getAverage(self):
"""Returns the average score."""
return sum(self. scores) / len(self._scores)

def getHighScore(self):
"""Returns the highest score."""
return max(self. scores)

def __str__(self):
"""Returns the string representation of the student."""
return "Name: " + self. name + "\nScores: " + \
" ".join(map(str, self. scores))

def __lt__(self, other):
"""Returns self = other, with respect
to names."""
return self. name >= other. name

def __eq__(self, other):
"""Tests for equality."""
if self is other:
return True
elif type(self) != type(other):
return False
else:
return self. name == other. name

def main():
"""Tests sorting."""
# Create the list and put 5 students into it
lyst = []
for count in reversed(range(5)):
s = Student("Name" + str(count + 1), 10)
lyst. append(s)

# Complete the definition of the main function

if __name__ == "__main__":
main()

ansver
Answers: 1

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 08:00
Two technicians are discussing the common u-joint. technician a says its input and output speeds should be equal. technician b says that it normally has two yokes. which technician is correct?
Answers: 1
question
Computers and Technology, 22.06.2019 23:30
For her science class, elaine is creating a presentation on weather in the united states. she wants to make the presentation beautiful and interesting by drawing simple cloud or wave shapes. which is the best way for elaine to draw these shapes?
Answers: 1
question
Computers and Technology, 23.06.2019 06:40
What are the three uses of a screw?
Answers: 2
question
Computers and Technology, 24.06.2019 04:30
How do you share someone else’s tweet with your own twitter followers?
Answers: 1
You know the right answer?
This project assumes that you have completed Project 1. Place several Student objects into a list an...
Questions
question
Mathematics, 02.11.2020 22:10
question
Chemistry, 02.11.2020 22:10
question
Mathematics, 02.11.2020 22:10
Questions on the website: 13722363