Created
June 28, 2022 10:58
-
-
Save mikekenneth/43dd1d48167d9c2c4f9bf5aee0be5a60 to your computer and use it in GitHub Desktop.
Rank list of scores
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Code pour calculer les rangs | |
def rank_scores(scores:list): | |
return {moyenne: rang for rang, moyenne in enumerate(reversed(sorted(set(moyennes))), start=1)} | |
moyennes = [1, 2, 20 , 16, 19, 18, 0, 6, 6.5, 12.5, 0.5, 15.60, 17.8] | |
ranked_scores = rank_scores(moyennes) | |
# Ensuites on peut recupere les range en entrant la moyennes comme input | |
ranked_scores.get(2) # 10 | |
ranked_scores.get(20) # 1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment