I'm trying to use loop and conditional to find a median for dice result. Here is the dice results
outcome / frequency
1:25
2:15
3:12
4:7
5:10
6:21
I know that the median is 3 because the total frequency of all dice results is 90 and the half of the result is 45 and the 45th dice is occurred by dice number 3. But I want to show it by computing it.
Here is the code I've tried. I know that i + i must be 50 for the first loop... That's why I'm stuck in here.
dict = {1:25, 2:15, 3:12, 4:7, 5:10, 6:21}
for i in dict.values():
if i+i > 45:
break
print(i) # 25
Aucun commentaire:
Enregistrer un commentaire