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 17:40
Consider the simple 3-station assembly line illustrated below, where the 2 machines at station 1 are parallel, i.e., the product only needs to go through one of the 2 machines before proceeding to station 2.what is the throughput time of this process?
Answers: 2
question
Computers and Technology, 22.06.2019 22:40
Least square fit to polynomial write a function leastsquarefit3pol that solves a linear system of equations to find a least squares fit of a third order polynomial to an experimental data set given as two row arrays. the function leastsquarefit3pol must explicitly solve a set of linear equations and cannot use polyfit. there should be no restriction on the size of the problem that can be solved.
Answers: 1
question
Computers and Technology, 23.06.2019 03:30
Ihave a singular monitor that is a tv for my computer. recently, i took apart my computer and put it back together. when i put in the hdmi cord and booted the computer to see if it worked, the computer turned on fine but the screen was blue with "hdmi no signal." i've tried everything that doesn't require buying spare parts, any answer is appreciated!
Answers: 1
question
Computers and Technology, 23.06.2019 11:00
This chapter lists many ways in which becoming computer literate is beneficial. think about what your life will be like once you’re started in your career. what areas of computing will be most important for you to understand? how would an understanding of computer hardware and software you in working from home, working with groups in other countries and contributing your talents.
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
Chemistry, 16.10.2020 04:01
question
Mathematics, 16.10.2020 04:01
question
Arts, 16.10.2020 04:01
Questions on the website: 13722362