Rectangle |
Code:
# Draw rectangle in turtle
from turtle import *
lengthOfRectangle = int(input("Enter the length of the Rectangle: "))
widthOfRectangle = int(input("Enter the width of the Rectangle: "))
for i in range(2):
# Drawing length of rectangle
# Forward turtle by lengthOfRectangle units
forward(lengthOfRectangle)
# Turn turtle by 90 degree
left(90)
# Drawing width of rectangle
# Forward turtle by widthOfRectangle units
forward(widthOfRectangle)
left(90)
# end for
# It will keep output to wait for the click,
# Otherwise output will be disappear.
exitonclick()
Input:
Enter the length of the Rectangle: 100
Enter the width of the Rectangle: 200
Output:
No comments:
Post a Comment