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 Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

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

%d bloggers like this: