Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # draw rectangle with turtle
- from turtle import Turtle
- tina = Turtle()
- def rec_area(h, l):
- return h * l
- def rec_perm(h, l):
- return h * l * 2
- def draw_rec(t_name,h, l, col):
- t_name.penup()
- t_name.color(col)
- t_name.pendown()
- t_name.goto(h,0)
- t_name.goto(h, l)
- t_name.goto(0, l)
- t_name.goto(0, 0)
- t_name.color("black")
- t_name.penup()
- t_name.goto (-125, 10)
- t_name.pendown()
- t_name.write("Area: "+ str(rec_area(h, l)))
- t_name.penup()
- t_name.goto(-125, -10)
- t_name.pendown()
- t_name.write("Circumference: "+ str(rec_perm(h, l)))
- draw_rec(tina, 200, 300, "blue")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement