## Posted By

maturanti19 on 05/22/19

# Hracie kocky

/ Published in: Python

Vytvorte program na hadzanie dvoma kockami a vypiste ich sucet

`import tkinterfrom random import * canvas = tkinter.Canvas(height=600, width=600, bg='gainsboro')canvas.pack()  def hraciakocka1(x):    global k    k=[0]*6    for i in range (x):        h=randrange(1,7)        k[h-1]=k[h-1]+1    print(k)x=int(input('Zadaj kolko krat mam hadzat na prvej kocke: '))hraciakocka1(x) def hraciakocka2(z):    global g    g=[0]*6    for i in range (z):        o=randrange(1,7)        g[o-1]=g[o-1]+1    print(g)z=int(input('Zadaj kolko krat mam hadzat dvomi kockami: '))##hraciakocka2(z) for i in range(6):    print('Na prvej kocke sa nachadza  ' + str(k[i]/x*100) + '%'+ ' pre cislo ' + str(i+1))print('')##for i in range(6):##    print('Na druhej kocke sa nachadza  ' + str(g[i]/x*100) + '%' + ' pre cislo ' + str(i+1)) def sucet(z):    global s    global k1    global g    s=[0]*11    for i in range(z):        k1=randrange(1,7)        g=randrange(1,7)        k1=k1+g        s[k1-2]=s[k1-2]+1    print(s)    for i in range(11):        print('sucet cisel na pozicii '+ str(i+2) +' je '+ str(s[i]))sucet(z) def graf(z):    canvas.create_line(50, 100, 50, 500, width = 5 )    canvas.create_line(50, 500, 450, 500, width = 5)    y=500    for i in range(11):        y1=10*s[i]/z*100        canvas.create_line(100+30*i, y, 100+30*i, y-y1, width = 15, fill='blue' )graf(z)`