## Posted By

maturanti19 on 05/22/19

# Random colours and rectangles mocniny

/ Published in: Python

Vytvorte stvorceky na nahodnom mieste s nahodnymi farbami Vypiste mocniny cisel do 20

`import tkinterfrom random import * canvas = tkinter.Canvas(height=600, width=800, bg='gainsboro')canvas.pack() #5 stvorcekov nahodne miesta a farby for i in range (1,6):    farba = choice(('thistle', 'skyblue', 'indigo', 'white', 'gray', 'violet', 'salmon'))    x=randrange(100,600)    y=randrange(100,800)    canvas.create_rectangle(x-15, y-15, x+15, y+15, fill=farba, outline='')    canvas.create_text(x, y, text= i, font='Georgia 20')  for i in range(20,31):    print(-i) print('Vsetky parne cisla od 0 po 50:')for i in range(0,51,2):    print(i) for i in range(0,26):    print(2*i) print()print('Vsetky neparne od 1 po 50 iny sposob:')for i in range(1,50, 3):    print(i) #mocniny vsetkych cisel do 20print()print('Druhe mocniny vsetkych cisel do 20:')for i in range(0,20):    print(i**2) print()print('Tretie mocniny vsetkych cisel do 20:')for i in range(0,20):    print(str(i) + ' na tretiu = ' + str(i*i*i))  for i in range(0,100):    farba = choice(('thistle', 'skyblue', 'indigo', 'white', 'gray', 'salmon', 'powderblue'))    canvas.create_line(400, 300, randrange(0,800), randrange(0,600), fill=farba, width=3) canvas.create_oval(390,290,410,310, fill='black', outline='')`