lehrkraefte:blc:informatik:glf4-20:simulation

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
lehrkraefte:blc:informatik:glf4-20:simulation [2021/03/26 15:21]
michael.greminger
lehrkraefte:blc:informatik:glf4-20:simulation [2021/03/26 15:31] (current)
michael.greminger
Line 51: Line 51:
 <hidden Lösungsvorschlag> <hidden Lösungsvorschlag>
 <code python> <code python>
-kommt bald...+from random import randint 
 + 
 +def sim(): 
 +    numbers = [] 
 +    for i in range(10): 
 +        z = randint(1,6)                # es wird gewürfelt 
 +        if (not z in numbers):          # wenn Zahl bis jetzt noch nicht gewürfelt 
 +            numbers.append(z)           # Zahl hinzufügen 
 +            if (len(numbers) == 6):     # wenn wir alle Zahlen haben 
 +                return 1                 
 +    return 0                            # nicht alle Zahlen wurden gewürfelt 
 + 
 +     
 +anzahlVersuche = 10000 
 +alleAugenzahlen = 0 
 +for i in range(anzahlVersuche): 
 +    alleAugenzahlen += sim() 
 +     
 +print alleAugenzahlen / anzahlVersuche
 </code>   </code>  
 </hidden> </hidden>
  • lehrkraefte/blc/informatik/glf4-20/simulation.1616768519.txt.gz
  • Last modified: 2021/03/26 15:21
  • by michael.greminger