## Posted By

maturanti19 on 05/22/19

# padajuca lopta a zavod auticok

/ Published in: Python

vytvorte zavod dvoch auticok aby vypisalo ktore je prve a padajuca lopta

`import tkinterfrom random import * canvas = tkinter.Canvas(height=600, width=800, bg='gainsboro')canvas.pack() def lopta():    canvas.delete('all')    global y    y=y+5    r=25    canvas.create_oval(100-r, y-r, 100+r, y+r, fill='skyblue', outline='')    if y<570:        canvas.after(100, lopta) def posun():    global x1, x2    a1=randrange(3,15)    x1=x1+a1    canvas.move('car1', a1,0)    a2=randrange(3,15)    x2=x2+a2    canvas.move('car2', a2, 0)    if (x1<700)and (x2<700):        canvas.after(100, posun)    if x1>=700:        canvas.create_text(600, 30, text='vyhral fialovy!')    elif x2>=700:        canvas.create_text(600,30, text='vyhral modry!') canvas.create_line(730, 50, 730, 270)canvas.create_text(730, 30, text='CIEL')  x1=20x2=20r=10canvas.create_rectangle(x1, 100, x1+50, 130, fill='lavender', outline='', tags='car1')canvas.create_oval(x1+10-r, 130-r, x2+10+r, 130+r, tags='car1', fill='black')canvas.create_oval(x1+35-r, 130-r, x2+35+r, 130+r, tags='car1', fill='black')canvas.create_rectangle(x2, 200, x2+50, 230, fill='skyblue', outline='', tags='car2')canvas.create_oval(x2+10-r, 230-r, x2+10+r, 230+r, tags='car2', fill='black')canvas.create_oval(x2+35-r, 230-r, x2+35+r, 230+r, tags='car2', fill='black') y=20#lopta()posun()`