Sunday, November 14, 2021

Draw diamond in python turtle

 

Diamond
Diamond

Code:

# Draw diamond in turtle
from turtle import *

length = int(input('Please enter length: '))
length=150
left(45) # Turn turtle by 45 degree

for i in range(4):
    forward(length) # Forward turtle by length 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:

Please enter length: 150

Output:

Diamond Output

No comments:

Post a Comment

Draw bahamas flag in python turtle

  Bahamas Flag