+ 1

How does python pick the highest score?

Lets say somebody played x number of games and the programme should pick the game with the highest points and print it out,how does python do that? A little illustration: G1 = 22 points G2 = 3 points G3 = 56 points G+=1 = …..points Print(”what code should be here?”)

1st Feb 2022, 12:39 AM
Lenoname
4 Antworten
+ 4
It 100% works games = [6,5,11,3] Highestscore = max(games) print(Highestscore)
1st Feb 2022, 2:43 AM
Abu Habban
Abu Habban - avatar
+ 5
Check which is greator highestscore = max(G1,G2,G3) print(highestscore)
1st Feb 2022, 12:47 AM
Abu Habban
Abu Habban - avatar
+ 1
Abu Habban What if its a list? Example games = [6,5,11,3] Highestscore = max(games) wouldnt work.
1st Feb 2022, 2:40 AM
Lenoname
+ 1
Yes you just need the max() function, built into python. Works on a list or a tuple (or any collection really).
1st Feb 2022, 3:37 PM
Erik