Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

relative ranks in python

def findRelativeRanks(score):
    copy_ver = score.copy()
    sorted_score = sorted(copy_ver, reverse=True)

    empty = {}
    for a,b in enumerate(sorted_score,1):
        empty[b] = str(a)

        if empty[b] == "1":
            empty[b] = "Gold Medal"
        if empty[b] == "2":
            empty[b] = "Silver Medal"
        if empty[b] == "3":
            empty[b] = "Bronze Medal"

    last = []
    for i in score:
        last.append(empty[i])

    return last
Source by eolnuha.com #
 
PREVIOUS NEXT
Tagged: #relative #ranks #python
ADD COMMENT
Topic
Name
7+6 =