Pseudo Python Writer

Project Managed by : Mohd Sufiyan Ansari

Social :

Back to HOMEPAGE

Some Example of Turtle Programs

Python Code

Pattern Output



from turtle import *
speed(200)
for i in range(90):
  forward(10-(i%5)*(i%5))
  left(76)

    
First Pattern




from turtle import *
import random as m
speed(2000)
penup()
goto(-40,0)
pendown()
for i in range(222):
  forward(80)
        k = 0
        if ( i % 6==0):
               k = 10
        left(60 + k)

    
Second Pattern




from turtle import *
speed(200)
for i in range(100):
  forward(100)
  left(99)

    
Third Pattern




from turtle import *
speed(200)
col = ['red','green','blue']
for i in range(200):
        color(col[i%3])
  forward(i)
  left(92)

    
Fourth Pattern





from turtle import *
speed(2000)
for i in range(190):
  forward(80-2*i)
  left(90)

    
Fifth Pattern




import turtle
r=turtle.Turtle()
r.penup()
r.goto(0,-180)
r.pendown()
r.color("yellow")
style=("Courier",20,"italic")
r.write("Stay Home ,Stay Safe",font=style,align="center")
r.hideturtle()
def d(s):
    for i in range (1,5):
        s.forward(90)
        s.right(90)
def dr():
    w = turtle.Screen()
    w.bgcolor("black")
    k = turtle.Turtle()
    k.shape("turtle")
    k.color("yellow")
    k.speed("fastest")
    k.pensize(2)
    for i in range(1,37):
        d(k)
        k.right(10)
    g = turtle.Turtle()
    an = turtle.Screen()
    g.shape("turtle")
    g.color("blue")
    g.speed("fastest")
    g.pensize(2)
    size=1
    h=1
    while h<74:
        g.forward(size)
        g.right(45)
        size = size + 1
        h+=1
    g.hideturtle()
    w.exitonclick()
dr()

    
Sixth Pattern

CodeSource : SoloLearn




Random Squares

from turtle import *
import random as rn
speed(500)
color_list = ['red','yellow','white','blue','green']
Screen().bgcolor('black')
for i in range(50):
  x = 355*rn.random()
  y = 335*rn.random()
  penup()
  goto(-155+x,200-y)
  pendown()
  color(color_list[i%5])
  right(90)
  forward(60)
  right(90)
  forward(40)
  right(90)
  forward(60)
  right(90)
  forward(40)

    
Seventh Pattern



Pyramid

from turtle import *
import time
speed(200000)
penup()
goto(-600,300)
pendown()
x = 0
y = 0
for r in range(6):
  goto(-600+x*(99/2),300-y*(85.7365))
  pendown()
  for j in range(6-r):
    for i in range(100):
      forward(i)
      right(120)
    left(120)
    penup()
    forward(50)
    right(90)
    forward(28.5788)
    left(90)
    pendown()
  penup()
  x += 1
  y += 1
    
Seventh Pattern

More Patterns Coming Soon...