Friday, September 11, 2020

Draw an Octagon using Python's Turtle Module (Computer Programming Language) - Code Sheet



 Hi, 

I am sharing the code sheet in Python language that you can copy and paste, as it is, onto the interfaces such as Pycharm and Intellij to get the Octagon in yellow colour. If you have any doubts, please let me know in the comment box.


import turtle
sanju = turtle.Turtle()
sanju.color("red", "yellow")
sanju.begin_fill()
sanju.forward(100)
sanju.left(45)
sanju.forward(100)
sanju.left(45)
sanju.forward(100)
sanju.left(45)
sanju.forward(100)
sanju.left(45)
sanju.forward(100)
sanju.left(45)
sanju.forward(100)
sanju.left(45)
sanju.forward(100)
sanju.left(45)
sanju.forward(100)
sanju.left(45)
sanju.end_fill()
turtle.done()

No comments:

Post a Comment

loading GIF

Blog Archive