Drawing using turtle in python
Open python shell , click File and select New File
and in a new file type the following code.
------------------------------------------------
import turtle # imports the turtle library
naS=input("Enter No.of sides") #specifies the no of sides
nS=int(naS)
for i in range(nS) : # for iteration begins
turtle.color('green') # remember to use the indentation until the end of iteration
turtle.forward(100) # draws a line forward
turtle.right(360/nS) # turns right and nS specifies the no of sides
Hit "F5" Sample Output for 5 Sides
>>>Enter No.of sides 5
naS=input("Enter No.of sides") #specifies the no of sides
nS=int(naS)
for i in range(nS) : # for iteration begins
turtle.color('green') # remember to use the indentation until the end of iteration
turtle.forward(100) # draws a line forward
turtle.right(360/nS) # turns right and nS specifies the no of sides
Hit "F5" Sample Output for 5 Sides
>>>Enter No.of sides 5