To draw a Hexagon using Python Turtle Graphics - Learn Engineering

All the news and updates relevant to Engineering. You can also Write a post here

Breaking

Monday, June 29, 2020

To draw a Hexagon using Python Turtle Graphics








Question

To draw a Hexagon using Python Turtle Graphics.

Sample TestCase Expected Output

  









Answer



# Python program to draw hexagon 
# using Turtle Programming 
import turtle  
polygon = turtle.Turtle() 
  
num_sides = 6
side_length = 70
angle = 360.0 / num_sides  
  
for i in range(num_sides): 
    polygon.forward(side_length) 
    polygon.right(angle) 
      
turtle.done() 

Follow Us For More...

No comments:

Post a Comment