30 lines
681 B
Python
30 lines
681 B
Python
|
import turtle as tt
|
||
|
from random import randint, random
|
||
|
|
||
|
def turtle_09():
|
||
|
"""Draw a pattern that will change each time the program is run. Use the
|
||
|
random function to pick the number of lines, the length of each line and
|
||
|
the angle of each turn."""
|
||
|
def rand_lines():
|
||
|
return randint(50, 150)
|
||
|
|
||
|
def rand_length():
|
||
|
return randint(150, 300)
|
||
|
|
||
|
def rand_angl():
|
||
|
return round(random()*360, 2)
|
||
|
|
||
|
lines = rand_lines()
|
||
|
length = rand_length()
|
||
|
angle = rand_angl()
|
||
|
|
||
|
tt.speed(100)
|
||
|
tt.bgcolor("black")
|
||
|
tt.color("magenta")
|
||
|
|
||
|
for _ in range(lines):
|
||
|
tt.left(angle)
|
||
|
tt.forward(length)
|
||
|
|
||
|
tt.exitonclick()
|