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

Other questions on the subject: Computers and Technology

image
Computers and Technology, 22.06.2019 11:00, terriblexsiren
You receive an email from an impressive-sounding stranger, professor alexander rothschild renard iii, president of the american institute for scientific political statesmen. he urges you to vote for his presidential candidate choice. this social media red flag is known as
Answers: 1
image
Computers and Technology, 22.06.2019 15:50, minideeri
The file sales data. xlsx contains monthly sales amounts for 40 sales regions. write a sub that uses a for loop to color the interior of every other row (rows 3, 5, etc.) gray. color only the data area, columns a to m. (check the file colors in excel. xlsm to find a nice color of gray.)
Answers: 2
image
Computers and Technology, 23.06.2019 04:31, hargunk329
Q13 what function does a security certificate perform? a. creates user accounts b. scrambles data c. identifies users d. creates password policies e. provides file access
Answers: 1
image
Computers and Technology, 23.06.2019 09:30, blake2001
Which of the following tasks is an audio technician most likely to perform while working on a nature documentary? (select all that apply). eliminating potentially distracting background noise adding sound effects making sure the lighting is adequate for a particular scene changing the narration to better match the mood of the documentary
Answers: 3
You know the right answer?
This project assumes that you have completed Project 1. Place several Student objects into a list an...

Questions in other subjects:

Konu
Mathematics, 29.06.2021 15:00
Konu
Computers and Technology, 29.06.2021 15:10