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