Find how many iterations taken to get 6 on a 6-face die
#rolling a 6-face dice
#calculate how many iterations needed to get 6
import random
n=1
iterations=0
while n>0:
n=random.randint(1,6)
if n==6:
print("Total iterations# ",iterations)
break#exit loop
iterations+=1
Comments
Post a Comment