Saturday, November 13, 2021

Draw square in python turtle

Square
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:

Square Output

No comments:

Post a Comment

Draw bahamas flag in python turtle

  Bahamas Flag