Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

High scores #13

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 62 additions & 1 deletion practice/high-scores/high_scores.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,64 @@
class HighScores:
"""
A class to represent a collection of high scores.

...

Attributes
----------
scores : list
a list of integers representing the scores

Methods
-------
latest():
Returns the latest (last) score.
personal_best():
Returns the highest score.
personal_top_three():
Returns the three highest scores, sorted in descending order.
"""

def __init__(self, scores):
pass
"""
Constructs all the necessary attributes for the HighScores object.

Parameters
----------
scores : list
a list of integers representing the scores
"""
self.scores = scores

def latest(self):
"""
Returns the latest (last) score.

Returns
-------
int
The latest score
"""
return self.scores[-1]

def personal_best(self):
"""
Returns the highest score.

Returns
-------
int
The highest score
"""
return max(self.scores)

def personal_top_three(self):
"""
Returns the three highest scores, sorted in descending order.

Returns
-------
list
The three highest scores
"""
return sorted(self.scores, reverse=True)[:3]
Loading