Advertisement
trodland

Terningkast - Kort kode

Sep 2nd, 2020
1,281
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.27 KB | None | 0 0
  1. import random
  2. resultat = [0,0,0,0,0,0]
  3. antall_kast = int(input("Hvor mange terningkast vil du gjøre? "))
  4. for i in range(antall_kast): resultat[random.randint(1,6)-1] += 1
  5. for i in range(6): print(f"{i+1} : {resultat[i]:<8} | Relativ frekvens: {resultat[i]/antall_kast:.3f}")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement