Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # error in the area of the rectangle
- from turtle import Turtle
- Tina = Turtle()
- x = input("Enter the distance on the axis x that you want your rectangle to be drawn: ")
- y = input("Enter the distance on the axis y that you want your rectangle to be drawn: ")
- width = input("Enter width: ")
- height = input("Enter height: ")
- color = input("What color do you want your rectangle?: ")
- def rectangle_area(width, height):
- return width * height # error: can't multiply sequence by non-int of type 'str'
- def rectangle_perimeter(width, height):
- return (width + height)*2
- def draw_rectangle(name, x, y, width, height, color):
- name.hideturtle() # to hide the turtle
- name.penup() # to move the invisible turtle to a position given by the input
- name.goto(0, 0) # begin at the centre of the screen
- name.pendown()
- name.color(color)
- name.begin_fill() # to fill in the rectangle with colour
- name.forward(width) # to begin drawing the rectangle, it can be all left or all right
- name.left(90)
- name.forward(height)
- name.left(90)
- name.forward(width)
- name.left(90)
- name.forward(height)
- name.left(90)
- name.end_fill() # to end the fill in with the colour given in the input
- name.penup() # to move the invisible turtle to begin writing the perimeter
- name.goto(0, -50) # error: it does not let me write (x, y - 10), it says it is a concatenate of str and int
- name.pendown()
- name.color("green")
- name.write("Rectangle of perimeter " + str(rectangle_perimeter(width, height)), align="center")
- name.penup() # to move the invisible turtle to begin writing the area
- name.goto(0, 50) # error: it does not let me write (x, y + 10), it says it is a concatenate of str and int
- name.pendown()
- name.color("green")
- name.write("Rectangle of area " + str(rectangle_area(width, height)), align="center")
- draw_rectangle(Tina, x, y, width, height, color)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement