Showing posts with label turtle. Show all posts
Showing posts with label turtle. Show all posts

Turtle race using python

import turtle

from random import *

from turtle import *

penup()

goto(-140,140)

for sp in range(15): 

  write(sp)

  right(90)

  forward(10)

  pendown()

  forward(150)

  penup()

  backward(160)

  left(90)

  forward(20)

x = Turtle() 

x.color('green') 

x.shape('turtle') 

x.penup() 

x.goto(-160,100) 

x.pendown() 

y = Turtle() 

y.color('red') 

y.shape('turtle') 

y.penup() 

y.goto(-160,80) 

y.pendown() 

turtlee = Turtle() 

turtlee.color('blue') 

turtlee.shape('turtle') 

turtlee.penup() 

turtlee.goto(-160,60) 

turtlee.pendown() 

for turn in range(100): 

  x.forward(randint(1,5)) 

  y.forward(randint(1,5)) 

  turtlee.forward(randint(1,5)) 

turtle.done()

Program to create infinity using turtle

from turtle import *

bgcolor("black")

color("yellow")

speed(11)

right(45)

for i in range(150):

circle(30)

if 7<i<62:

left(5)

if 80<i<133:

right(5)

if i<80:

forward(10)

else:

forward(5)

Generate Captcha Using Python


from captcha.image import ImageCaptcha

image = ImageCaptcha(width = 280, height = 90)

captcha_text = 'python'

data = image.generate(captcha_text)

image.write(captcha_text,'CAPTCHA.png')


Drawing Corona Virus Using Turtle

from turtle import *

color('green')

bgcolor('black')

speed(10)

hideturtle()

b = 0

while b < 200:

right( b)

forward(b * 3)

b = b + 1

PROGRAM TO CREATE INSTAGRAM LOGO IN PYTHON TURTLE

from turtle import  *

speed(5)

def om(x,y):

    penup()

    goto(x,y)

    pendown()

def om1(x,y,f,c,c1,c2):

    color(c)

    om(x,y)

    begin_fill()

    for i in range(4):

        forward(f)

        circle(c1,c2)

    end_fill()

def om2(c,x,y,c1):

    color(c)

    begin_fill()

    om(x, y)

    circle(c1)

    end_fill()


om1(-150,-120,350,"black",20,90)

om1(-110,-70,260,"white",20,90)

om1(-90,-50,220,"black",20,90)

om2("white",20,10,70)

om2("black",20,30,50)

om2("white",110,160,15)


color("black")

om(-120,-180)

write("INSTAGRAM",font=("Helvetica",40,"bold"))

hideturtle()

done()

Plotting Star Using Turtle

import turtle

s = turtle.Turtle()

s.right(75)

s.forward(100)

for i in range(4):

s.right(144)

s.forward(100)

turtle.done()


Colorful Spiral Web Using Turtle Graphics in Python

import turtle

colors = ['red', 'yellow', 'green', 'purple', 'blue', 'orange']

s= turtle.Pen()

s.speed(10)

turtle.bgcolor("black")

for x in range(200):

s.pencolor(colors[x%6]) 

s.width(x/100 + 1) 

s.forward(x) 

s.left(59) 

turtle.done()

s.speed(20)

turtle.bgcolor("black") 

for x in range(200):

s.pencolor(colors[x%6]) 

s.width(x/100 + 1) 

s.forward(x) 

s.left(59) 

turtle.done()