< Kurs:Python < LG < Py2009

Einfacher Würfel

import random

zahl = random.randint(1,6)
print zahl

Zahlenreihe

import random

for i in range (0, 20):
    zahl = random.randint(1,6)
    print zahl

Protokoll (hier in einer Zeile!):

5, 2, 3, 5, 1, 1, 1, 3, 4, 5, 4, 6, 5, 3, 2, 2, 6, 2, 2, 6

Häufigkeit

1 2 3 4 5 6
3 5 3 2 4 3

Summe: 20 Zahlen

This article is issued from Wikiversity. The text is licensed under Creative Commons - Attribution - Sharealike. Additional terms may apply for the media files.