Sunday, November 14, 2021

Draw hexagon in python turtle

  

Hexagon
Hexagon

Code:

# Draw hexagon in turtle
from turtle import *

length = int(input('Please enter length: '))

for i in range(6):
    forward(length)  # Forward turtle by length units
    left(60)  # Turn left turtle by 60 degree
# end for

# It will keep output to wait for the click,
# Otherwise output will be disappear.
exitonclick()

Input:

Please enter length: 100

Output:

No comments:

Post a Comment

Draw bahamas flag in python turtle

  Bahamas Flag