Код:
from turtle import *
pensize(10)
c = 'red'
for _ in range(10):
if c == 'red':
c = 'green'
else:
c = 'red'
color(c)
forward(30)
Код:
from turtle import *
pensize(10)
c = 'red'
for _ in range(10):
if c == 'red':
c = 'green'
else:
c = 'red'
color(c)
forward(30)
Код:
import time
from turtle import *
colors = (
('red', 'black', 'black'),
('red', 'yellow', 'black'),
('black', 'black', 'green'),
('black', 'yellow', 'black')
)
speed(0)
try:
while True:
for block in range(4):
for light in range(3):
setpos(0, - light * 100)
pendown()
color('white', colors[block][light])
begin_fill()
circle(50)
end_fill()
penup()
time.sleep(.3)
except KeyboardInterrupt:
pass
Виконати цей код на Repl.It: https://repl.it/@ttolich/trafficlights#main.py
Код:
from turtle import *
import random
speed(0)
shape('circle')
for _ in range(71):
color('#%06x' % random.randint(0, 0xFFFFFF))
stamp()
circle(190, 5)
Виконати цей код на Repl.It: https://repl.it/@ttolich/bracelet
Код:
from turtle import *
def triangle(x):
left(30)
begin_fill()
for i in range(3):
forward(x)
right(120)
end_fill()
right(30)
forward(x // 3)
while x <= 130:
return triangle(x + 30)
speed(5)
color('green')
right(90)
triangle(40)
Виконати цей код на Repl.It: https://repl.it/@ttolich/tree