## Posted By

maturanti19 on 05/22/19

# Stvorceky aj sachovnica

/ Published in: Python

Vyrvorte sachovnicu dvoch roznych farieb a vytvorte stvorceky ktore sa budu zalamovat, zistite ci je cislo zaporne alebo kladne Create chess base and different rectangles which will break when hit canvas

`import tkinterfrom random import *canvas=tkinter.Canvas(bg='gainsboro', height=800, width=800)canvas.pack() n=int(input('Zadaj ci ma byt cislo kladne alebo zaporne: '))if n<0:    print('zaporne')elif n==0:    print('nula')else:    print('kladne') #100 stvorcekov na konci riadku zalomit def stvorcek():    canvas.create_rectangle(x,y,x+50,y+50) x=50y=10for i in range(100):    if x+100>800:        x=50        y=y+60    stvorcek()    x=x+60 def stvorcekyfarebne():        d=20        x=20        y=20        farba='blue'        for i in range(100):            if x+d>800:                x=20                y=y+d+5            canvas.create_rectangle(x,y,x+d,y+d, fill=farba)            x=x+d+5            if farba=='blue':farba='red'            else: farba='blue'stvorcekyfarebne()`