Colorful Python
1 WAP to make love using turtle
from turtle import *
bgcolor("pink"); color("white","red")
width(4);left(122);forward(120)
begin_fill()
circle(-32,185);left(125)
circle(-37,185); home()
end_fill()
ht(); done()
output
2 WAP to make Square Spirograph using turtle
import turtle
turtle.speed(0)
turtle.bgcolor("black")
for i in range(5):
for colours in ["red","magenta","blue","cyan","green","yellow","white"]:
turtle.color(colours)
turtle.pensize(3)
turtle.left(12)
turtle.forward(200)
turtle.left(90)
turtle.forward(200)
turtle.left(90)
turtle.forward(200)
turtle.left(90)
turtle.forward(200)
turtle.left(90)
output
3 WAP to make Circle Spirograph using turtle
import turtle
turtle.speed(0)
turtle.bgcolor("black")
turtle.pensize(2)
for i in range(6):
for colours in ["red","magenta","blue","cyan","green","yellow","white"]:
turtle.color(colours)
turtle.circle(100)
turtle.left(10)
turtle.hideturtle()
output
4 WAP to make spider web
import turtle
t = turtle.Turtle()
s = turtle.Screen()
s.bgcolor("black")
t.pencolor("white")
a = 0
b = 0
t.speed(0)
t.penup()
t.goto(0,200)
t.pendown()
while True:
t.forward(a)
t.right(b)
a+=3
b+=1
if b ==210:
break
t.hideturtle()
output
5 WAP
from turtle import *
circle(120, 360/2)
begin_fill()
circle(120, 360/2)
end_fill()
pu(); lt(90); fd(60)
dot(120, "white"); dot(35, "black")
fd(120)
dot(120, "black"); dot(35, "white")
ht(); done()
output
6 WAP
from turtle import *
##
tracer(0); width(5)
color("yellow", "blue"); bgcolor("black")
points = []; size = 300; sides = 9 # selectable number of sides
pu(); sety(-size); pd() # start here
##
begin_fill()
for i in range(sides): # collect data
points.append(pos())
circle(size, 360/sides)
end_fill()
##
for start in points:
for end in points:
goto(start); goto(end) # connect points
done()
output
7 WAP to make ivory cross
from turtle import *
shape("square")
shapesize(1.6, 5); stamp() # Horizontal black
lt(90); bk(50)
shapesize(1.6, 10); stamp() # Vertical black
color("ivory"); fd(50); lt(90)
shapesize(1.1, 4.6); stamp() # Horizontal ivory
lt(90); fd(50)
shapesize(1.1, 9.65); stamp() # Vertical ivory
done()
8 Example of colorful python
from turtle import *
ht(); pu(); bgcolor("black")
colors = ["pink", "blue", "green", "yellow", "red"]
sqrSize = 40 #pixels.Change to taste
shape("square"); shapesize(sqrSize/20)
sqrDiag = sqrSize*2**0.5
for nextColor in colors:
color(nextColor)
stamp()
lt(45); fd(sqrDiag); rt(45)
ht; done()
from turtle import *
ht(); width(8) # Star of David
color('blue'); bgcolor("white"); size = 80
for i in range(6):
for j in range(3):
fd(size); rt(120)
fd(size); lt(60)
done()
output
10] WAP to make ironman face using turtle
import turtle
# top part
piece1=[
[(-40, 120), (-70, 260), (-130, 230), (-170, 200), (-170, 100), (-160, 40), (-170, 10), (-150, -10), (-140, 10), (-40, -20), (0, -20)],
[(0, -20), (40, -20), (140, 10), (150, -10), (170, 10), (160, 40), (170, 100), (170, 200), (130, 230), (70, 260), (40, 120), (0, 120)]
]
piece2=[
[(-40, -30), (-50, -40), (-100, -46), (-130, -40), (-176, 0), (-186, -30), (-186, -40), (-120, -170), (-110, -210), (-80, -230), (-64, -210), (0, -210)],
[(0, -210), (64, -210), (80, -230), (110, -210), (120, -170), (186, -40), (186, -30), (176, 0), (130, -40), (100, -46), (50, -40), (40, -30), (0, -30)]
]
piece3=[
[(-60, -220), (-80, -240), (-110, -220), (-120, -250),(-90, -280), (-60, -260), (-30, -260), (-20, -250), (0, -250)],
[(0, -250), (20, -250), (30, -260), (60, -260), (90, -280), (120, -250),(110, -220), (80, -240), (60, -220), (0, -220)]
]
turtle.hideturtle()
turtle.bgcolor('#ba161e') #Dark Red
turtle.setup(500,600)
turtle.title("I AM IRONMAN")
piece1Goto=(0,120)
piece2Goto=(0,-30)
piece3Goto=(0,-220)
turtle.speed(2)
def draw_piece(piece,pieceGoto):
turtle.penup()
turtle.goto(pieceGoto)
turtle.pendown()
turtle.color('#fab104') #Light Yellow
turtle.begin_fill()
for i in range(len(piece[0])):
x,y=piece[0][i]
turtle.goto(x,y)
for i in range(len(piece[1])):
x,y=piece[1][i]
turtle.goto(x,y)
turtle.end_fill()
draw_piece(piece1,piece1Goto)
draw_piece(piece2,piece2Goto)
draw_piece(piece3,piece3Goto)
turtle.hideturtle()
turtle.done()
output
11] WAP to make a design ring art design
import turtle
turtle.bgcolor('black')
turtle.speed(0)
turtle.pencolor('blue')
turtle.pensize(2)
turtle.penup()
turtle.goto(-100,-55)
turtle.pendown()
for i in range(100):
turtle.forward(200)
turtle.left(115)
turtle.hideturtle()
turtle.done()
output
12] WAP to design in turtle
import turtle
turtle.bgcolor('black')
turtle.speed(0)
turtle.pencolor('blue')
turtle.pensize(1)
turtle_range=500
for i in range(turtle_range):
print(i)
if i !=(turtle_range-1):
turtle.forward(i)
else:
turtle.forward(turtle_range/2)
turtle.left(91)
turtle.hideturtle()
turtle.done()
output
0 Comments