Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from turtle import Turtle
- tom = Turtle()
- def rect_area(width, height):
- return width * height
- def rect_perimeter(width, height):
- return 2*width + 2*height
- def draw_rectangle(tom, width, height, color):
- tom.color(color)
- tom.forward(height)
- tom.left(90)
- tom.forward(height)
- tom.left(90)
- tom.forward(width)
- tom.left(90)
- tom.forward(height)
- tom.left(90)
- tom.forward(width)
- tom.penup()
- tom.color("black")
- tom.goto(-50,100)
- tom.write("Area: " + str(rect_area(width, height)), align = "center" )
- tom.goto(-50, 80)
- tom.write("Perimeter: " + str(rect_perimeter(width,height)), align = "center")
- tom.hideturtle()
- draw_rectangle(tom,500,200, "blue")
Advertisement
Add Comment
Please, Sign In to add comment