n-gon function using Turtle – Python

 -*- coding: utf-8 -*-
"""
Created on Fri Sep 16 18:00:00 2016

@author: Shruti
"""
#Program to take arguments to draw ngon 
import turtle

t = turtle.Pen()

def ngon(x):
 side_length = 30
 myangle = 360 / x
 for i in range(x):
 t.forward(side_length)
 t.right(myangle)
 
ngon(5)


###############
def ngon2(x,s):
 angle=360/x
 for i in range(x):
 t.fd(s)
 t.rt(angle)
 
ngon2(5,60)

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.