Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
45
Task/Simple-turtle-graphics/Python/simple-turtle-graphics.py
Normal file
45
Task/Simple-turtle-graphics/Python/simple-turtle-graphics.py
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
from turtle import *
|
||||
|
||||
def rectangle(width, height):
|
||||
for _ in range(2):
|
||||
forward(height)
|
||||
left(90)
|
||||
forward(width)
|
||||
left(90)
|
||||
|
||||
def square(size):
|
||||
rectangle(size, size)
|
||||
|
||||
def triangle(size):
|
||||
for _ in range(3):
|
||||
forward(size)
|
||||
right(120)
|
||||
|
||||
def house(size):
|
||||
right(180)
|
||||
square(size)
|
||||
triangle(size)
|
||||
right(180)
|
||||
|
||||
def barchart(lst, size):
|
||||
scale = size/max(lst)
|
||||
width = size/len(lst)
|
||||
for i in lst:
|
||||
rectangle(i*scale, width)
|
||||
penup()
|
||||
forward(width)
|
||||
pendown()
|
||||
penup()
|
||||
back(size)
|
||||
pendown()
|
||||
|
||||
clearscreen()
|
||||
hideturtle()
|
||||
house(150)
|
||||
penup()
|
||||
forward(10)
|
||||
pendown()
|
||||
barchart([0.5, (1/3), 2, 1.3, 0.5], 200)
|
||||
penup()
|
||||
back(10)
|
||||
pendown()
|
||||
Loading…
Add table
Add a link
Reference in a new issue