dimanche 30 août 2015

Print variables in order based on pseudo-random numbers

I am creating a task where a person receives a score based on their accuracy. Then they are presented with a screen with their performance place among other players (where the other players' scores are randomly generated numbers.)

I need to generate random scores for the fake players, then somehow sort the scores in descending order based on their placement. The only real score that is presented will be [sub_score].

Below is what I have so far. I'm not sure how to sort these variables based on their values, then print the variables for [firstplace], [secondplace], [thirdplace], etc. Also, this needs to occur 4 times, where each time a different score is generated for the fake players, and their placement fluctuates across tasks. These randomly generated numbers should fall between 70-90 since these scores reflect accuracy.

import random
'jsw_score' = random.randint(70,90)
'jbp_score' = random.randint(70,90)
'bsp_score' = random.randint(70,90)
'mjk_score' = random.randint(70,90)
'phs_score' = random.randint(70,90)
'msw_score' = random.randint(70,90)
'tdl_score' = random.randint(70,90)
'aik_score' = random.randint(70,90)
'wjc_score' = random.randint(70,90)
'sub_score' = accuracy

Thank you!




Aucun commentaire:

Enregistrer un commentaire