Computers and Technology
Computers and Technology, 01.12.2020 01:20, keltaylor

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()

answer
Answers: 1

Other questions on the subject: Computers and Technology

image
Computers and Technology, 21.06.2019 17:00, laylay120
The most efficient way to establish top best possible economize position is to measure
Answers: 1
image
Computers and Technology, 22.06.2019 01:40, genyjoannerubiera
Kali, a python programmer, is using the turtle module to write the word ā€œhello.ā€ which code should she use to indicate the location to begin writing the word? a # pick up the turtle and move it to its starting location. b penup(-100, 200) goto() pendown() c penup() goto(-100, 200) pendown() d # pick up the turtle and move it to (-100, 200)
Answers: 2
image
Computers and Technology, 24.06.2019 19:20, maehardy4134
Kiesha has a worksheet with a range of cells using the following columns: name, score, group, study group, and date. kiesha needs to sort the worksheet on the date field. which option she use to most efficiently complete this task ? a use the cut and paste option to reorganize the data to fit that order b use the filter function to organize the data based on the date c use the order function to organize the data based on the date d use the sort function to organize the data based on date order
Answers: 3
image
Computers and Technology, 25.06.2019 07:50, joshbee2014
Assignment: permutations use the permutation formula ļ€Ø ļ€© r ! ! n n p nr ļ€½ ļ€­ to solve each problem. be sure to show all work leading to your answer. part i: solve real-world permutation problems choose any four (4) of the following five problems to solve. for each problem a) show how the permutation formula can be used to find the answer and b) write a sentence to explain the meaning of the answer for the situation. 1. to register for online banking services at a local credit union, you need to select a four-digit personal identification number, or pin code. the digits cannot be repeated. how many ways are there to arrange four digits out of the numerals 0 through 9 to create a code?
Answers: 3
Do you know the correct answer?
This project assumes that you have completed Project 1. Place several Student objects into a list an...

Questions in other subjects:

Konu
Social Studies, 19.08.2019 05:00
Konu
English, 19.08.2019 05:00