Turtle Spiral Art by PyCoder

.
0

Turtle graphics with Python 

Turtle is python library, This library provided most of the feature like a drawing board, using this library we can create graphics,games,pictures and much more. 

How to use turtle library in our program? 


1. First you have to import turtle library 

import turtle

2. Create Object of the turtle
t=turtle.Turtle()
If you aren't create the object of turtle,no problem but you have to write 'turtle.' before the any action, but it's make your code so long 

Complete more than 10 turtle different shapes created in program 


Source Code:

import turtle

t=turtle.Turtle()

t.speed(4500)

t.color('cyan')

t.screen.bgcolor('black')



def circle(p):

for i in range(75):

t.circle(40)

t.left(p)



def square(tf,left,r):

f=60

for i in range(r):

t.fd(f)

t.left(tf)

t.fd(f)

t.left(tf)

t.fd(f)

t.left(tf)

t.fd(f)

t.left(left)



def spiral(left):

for i in range(109):

for color in ['white','cyan']:

t.color(color)

t.fd(i)

t.left(left)



def help(x,y):

t.penup()

t.goto(x,y)

t.pendown()



circle(10)

help(-300,100)

square(30,130,90)

help(90,270)

square(90,100,80)

help(-90,-170)

square(102,30,50)

help(150,150)

square(-30,200,80)

help(-180,-150)

square(45,301,100)

help(-180,450)

square(100,22,80)

help(250,-200)

square(302,13,90)

help(300,450)

spiral(30)

help(-300,-520)

spiral(50)

help(0,-450)

spiral(188)

help(100,500)

square(810,1,60)

help(-290,230)

square(-50,560,80)



turtle.done()

Circle spiral shape 
Code:
import turtle
t=turtle.Turtle()
t.speed(4500)
t.color('cyan')
t.screen.bgcolor('black')
for i in range(75):
t.circle(70)
t.left(10)
turtle.done()


Output :

Multiple square shape 
import turtle
t=turtle.Turtle()
t.speed(4500)
t.color('cyan')
t.screen.bgcolor('black')

def square(tf,left,r):
f=60
for i in range(r):
t.fd(f)
t.left(tf)
t.fd(f)
t.left(tf)
t.fd(f)
t.left(tf)
t.fd(f)
t.left(left)
square(30,130,90)

turtle.done()
Output :

Post a Comment

0Comments
Post a Comment (0)

#buttons=(Accept !) #days=(20)

Our website uses cookies to enhance your experience. Learn More
Accept !