Advertisement
zhongnaomi

draw_rectangle and area

Jan 28th, 2019
263
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.58 KB | None | 0 0
  1. from turtle import *
  2.  
  3.  
  4. def rectangle_area(height,length):
  5.    
  6.     area =int(height)* int(length)
  7.     return area
  8.    
  9. def draw_rectangle(length,height):
  10.    
  11.     hideturtle()
  12.    
  13.    
  14.     begin_fill()
  15.     color("green")
  16.     forward (length)
  17.     right (90)
  18.     forward (height)
  19.     right (90)
  20.     forward (length)
  21.     right (90)
  22.     forward (height)
  23.     right (90)
  24.     end_fill()
  25.     penup()
  26.     color("blue")
  27.     goto((length/2),(-height/2))
  28.     pendown()
  29.     write("Area: " + str(rectangle_area(height,length)), align="center")
  30.  
  31.  
  32.  
  33.    
  34. draw_rectangle(100,200)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement