Wednesday, October 6, 2021

Happy Birthday Using Python Turtle Graphics

 Happy Birthday Using Python Turtle Graphics:


import turtle

ankita = turtle.Screen()
ankita.bgcolor("black")
tech_habit = turtle.Turtle()
tech_habit.width(7)
colors = ["#f5ac2f", "#279cf5", "#d820f5", "#a2f52f", "#f527c1"]


def draw_ankita(i, x, y):
tech_habit.pencolor("linen")
tech_habit.color(colors[i % 7])
tech_habit.lt(70)
tech_habit.penup()
tech_habit.goto(x, y)
tech_habit.pendown()
tech_habit.circle(22)
tech_habit.end_fill()


def ballon(x, y):
tech_habit.pensize(4)
for i in range(5):
draw_ankita(i, x, y)


def f1():
for i in range(7):
tech_habit.pensize(5)
tech_habit.pencolor('light blue')
tech_habit.color(colors[i % 19])
tech_habit.begin_fill()
tech_habit.left(330)
tech_habit.forward(55)
tech_habit.begin_fill()
tech_habit.rt(110)
tech_habit.circle(33)
tech_habit.end_fill()
tech_habit.rt(11)
tech_habit.backward(33)
tech_habit.end_fill()


def cake(x, y):
tech_habit.fd(x)
tech_habit.rt(90)
tech_habit.fd(y)
tech_habit.rt(90)
tech_habit.fd(x)
tech_habit.rt(90)
tech_habit.fd(y)


def move(x, y):
tech_habit.up()
tech_habit.setposition(0, 0)
tech_habit.setheading(90)
tech_habit.rt(90)
tech_habit.fd(x)
tech_habit.lt(90)
tech_habit.fd(y)
tech_habit.pendown()


def mov(x, y):
tech_habit.up()
tech_habit.setposition(0, 0)
tech_habit.setheading(90)
tech_habit.lt(90)
tech_habit.fd(x)
tech_habit.rt(90)
tech_habit.fd(y)
tech_habit.pendown()


def A(size):
tech_habit.rt(19)
tech_habit.forward(size)
tech_habit.rt(141)
tech_habit.fd(size)
tech_habit.backward(size / 2)
tech_habit.rt(105)
tech_habit.fd(int(size / 3))


def B(size):
tech_habit.forward(size)
tech_habit.rt(90)
for i in range(18):
tech_habit.rt(9)
tech_habit.fd(size // 20)
for i in range(18):
tech_habit.rt(size // 5)
tech_habit.backward(size // 20)


def D(size):
tech_habit.fd(size)
tech_habit.rt(90)
tech_habit.fd(size // 10)
for i in range(13):
tech_habit.rt(13)
tech_habit.fd(size // 8)


def E(size):
tech_habit.rt(90)
tech_habit.fd(int(size / 3))
tech_habit.back(int(size / 3))
tech_habit.left(90)
tech_habit.fd(size / 2)
tech_habit.rt(90)
tech_habit.fd(int(size / 3))
tech_habit.back(int(size / 3))
tech_habit.lt(90)
tech_habit.fd(size / 2)
tech_habit.rt(90)
tech_habit.fd(int(size / 3))


def H(size):
tech_habit.fd(size)
tech_habit.backward(size // 2)
tech_habit.rt(90)
tech_habit.fd(size // 2)
tech_habit.lt(90)
tech_habit.fd(size // 2)
tech_habit.backward(size)


def I(size):
tech_habit.fd(size)
tech_habit.rt(90)
tech_habit.circle(size // 8)

def L(size):
tech_habit.rt(90)
tech_habit.fd(int(size / 2))
tech_habit.back(int(size / 2))
tech_habit.lt(90)
tech_habit.fd(size)

def N(size):
tech_habit.fd(size)
tech_habit.rt(150)
tech_habit.fd(size + int(size / 6))
tech_habit.lt(150)
tech_habit.fd(size)


def P(size):
tech_habit.fd(size)
tech_habit.rt(90)
tech_habit.fd(size // 8)
for i in range(8):
tech_habit.rt(20)
tech_habit.fd(size // 9)

def R():
tech_habit.fd(60)
tech_habit.rt(90)
tech_habit.fd(7)
for i in range(15):
tech_habit.rt(12)
tech_habit.fd(3)
tech_habit.lt(120)
tech_habit.fd(40)


def S(size):
tech_habit.rt(90)
for i in range(0, 5):
if i < 3:
tech_habit.fd(size / 2)
tech_habit.lt(90)
if i == 2:
tech_habit.rt(90)
else:
tech_habit.right(90)
tech_habit.fd(size / 2)


def T(size):
tech_habit.fd(size)
tech_habit.rt(90)
tech_habit.fd(size // 2)
tech_habit.backward(size // 2)


def Y(size):
tech_habit.fd(size)
tech_habit.left(60)
tech_habit.fd(size // 2)
tech_habit.backward(size // 2)
tech_habit.rt(90)
tech_habit.fd(size // 1.5)

tech_habit.speed(19)


mov(120, 30)
tech_habit.color("#f7b543")
# tech_habit.color(colors[8 % 5])
tech_habit.begin_fill()
cake(40, 180)
tech_habit.end_fill()
mov(110, 75)
tech_habit.color("#d152f7")
tech_habit.begin_fill()
cake(40, 160)
tech_habit.end_fill()
mov(100, 120)
tech_habit.color("#f54eb8")
tech_habit.begin_fill()
cake(40, 140)
tech_habit.end_fill()
mov(30, 170)
tech_habit.width(11)
tech_habit.pencolor("red")
tech_habit.circle(7)
move(180, 307)
mov(0, 0)
ballon(-490, 200)
ballon(490, 200)
ballon(183, -150)
ballon(-133, -150)

tech_habit.speed(7)
tech_habit.width(9)
tech_habit.pencolor("#319df5")
mov(260, 205)
N(size=70)

tech_habit.width(11)
mov(190, 205)
I(70)
mov(160, 205)
L(size=70)
mov(110, 205)
E(size=70)
mov(70, 205)
S(size=70)
mov(20, 205)
H(size=70)
mov(-30, 205)
tech_habit.pencolor("#95ed28")
style = ('Arial', 50, 'italic')
tech_habit.write("(DADA)", font=style)

tech_habit.pencolor("cyan")
tech_habit.width(13)
mov(260, -80)
H(100)
tech_habit.width(7)
mov(190, -80)
A(65)
mov(135, -80)
P(60)
mov(100, -80)
P(60)
mov(52, -80)
Y(60)
mov(28, -80)
B(60)
move(12, -80)
I(60)
move(36, -80)
R()
move(80, -80)
T(100)
move(102, -80)
H(60)
move(150, -80)
tech_habit.pencolor('hotpink')
D(200)
move(160, -80)
A(60)
move(220, -80)
Y(60)
ankita.exitonclick()

Wednesday, September 15, 2021

Shinchan Using Python Turtle

Source Code Shinchan Using Python Turtle:

from turtle import *

# import time
s = Screen()
s.screensize(700, 1000)
speed(13)


def myPosition(x, y):
penup()
goto(x, y)
pendown()


# time.sleep(10)
# ht()
pensize(2)


def ankita():
fillcolor('#ffec40')
begin_fill()
right(25)
forward(20)
right(45)
forward(20)
left(70)
forward(90)
left(95)
forward(75)
left(85)
forward(175)
left(85)
forward(75)
left(95)
forward(90)
left(85)
forward(18)
end_fill()


def leftLeg():
myPosition(-39, -25)
fillcolor("#ffd699")
begin_fill()
right(89)
forward(25)
right(90)
forward(50)
right(90)
forward(20)
right(85)
forward(50)
end_fill()


def leftSock():
myPosition(-36, -78)
fillcolor("#ffffff")
begin_fill()
right(90)
circle(80, 13)
right(110)
forward(22)
right(85)
forward(19)
right(90)
forward(21)
end_fill()


def leftShoe():
myPosition(-69, -112)
fillcolor("black")
begin_fill()
right(90)
left(5)
forward(56)
left(105)
forward(13)
left(75)
forward(20)
right(90)
forward(15)
circle(10, 15)
left(80)
forward(4)
circle(10, 15)
left(40)
circle(20, 15)
forward(10)
right(45)
forward(15)
circle(25, 25)
end_fill()


def rightLeg():
myPosition(60, -28)
fillcolor("#ffd699")
begin_fill()
# right(90)
left(128)
forward(25)
right(95)
forward(55)
right(90)
forward(20)
right(85)
forward(55)
end_fill()


def rightSock():
myPosition(64, -79)
fillcolor("#ffffff")
begin_fill()
right(90)
circle(90, 14)
right(110)
forward(23)
right(90)
forward(15)
right(80)
forward(21)
end_fill()


def rightShoe():
myPosition(64, -108)
fillcolor("black")
begin_fill()
right(100)
forward(56)
left(160)
forward(25)
right(68)
forward(17)
left(90)
circle(18, 15)
forward(5)
left(75)
forward(11)
right(85)
forward(20)
left(45)
circle(10, 30)
left(25)
forward(5)
end_fill()


def myShirt():
myPosition(-75, 48)
fillcolor("red")
begin_fill()
left(72)
forward(185)
left(87)
forward(75)
right(68)
circle(20, 8)
circle(300, 23)
left(90)
circle(35, 17)
right(38)
circle(35, 17)
left(58)
forward(75)
right(12)
forward(140)
right(40)
forward(93)
left(120)
circle(-20, 65)
left(75)
forward(10)
left(23)
forward(88)
# circle(-80,10)
right(31)
forward(87)
right(180)
forward(108)
right(180)
forward(104)
circle(10, 70)
end_fill()


def myHead():
myPosition(-20, 295)
left(20)
pensize(2)
fillcolor('#fcc6a0')
begin_fill()
right(90)
forward(40)
right(90)
circle(50, 80)
left(10)
circle(50, 80)
left(2)
circle(200, 50)

left(48)
forward(60)
# left(20)
circle(45, 60)
right(5)
circle(100, 85)
end_fill()
fillcolor('black')
begin_fill()

pensize(2)
right(170)
circle(-100, 165)
right(78)
forward(26)
right(87)
forward(55)
circle(45, 60)
right(5)
circle(100, 85)
end_fill()

fillcolor('#fcc6a0')
begin_fill()
right(180)
circle(-100, 105)
right(37)
forward(49)
pensize(2)
left(130)
forward(30)
# right(5)
circle(-10, 70)
right(50)
# circle(10,10)
forward(36)
right(80)
forward(50)
pencolor('#fcc6a0')
right(90)
forward(30)

end_fill()


def rightHand():
# left(35)
myPosition(197, 209)
pencolor('black')
fillcolor('#fcc6a0')
begin_fill()
right(45)
forward(6)
left(55)
forward(20)
circle(-5, 70)
right(100)
forward(18)
left(105)
forward(18)
circle(-5, 70)
right(100)
forward(18)
left(145)
forward(15)
circle(-5, 70)
right(100)
forward(18)

left(150)
forward(13)
circle(-5, 70)
right(100)
forward(15)

left(150)
forward(10)
circle(-5, 70)
right(100)
forward(12)
circle(60, 10)
left(45)
forward(6)
right(90)
forward(10)
end_fill()


def leftHand():
myPosition(-94, 242)
fillcolor('#fcc6a0')
begin_fill()
right(10)
forward(6)
left(90)
penup()
forward(12)
pendown()
left(90)
forward(8)
left(90)
forward(12)
end_fill()


def myBis():
myPosition(-103, 291)
right(90)
fillcolor('#02d302')
begin_fill()
right(90)
forward(55)
left(80)
forward(12)
left(10)
forward(17)
left(10)
forward(12)
left(80)
forward(55)
left(80)
forward(12)
left(10)
forward(17)
left(10)
forward(12)
left(80)
left(80)
forward(12)
left(10)
forward(17)
left(10)
forward(12)
end_fill()
penup()
right(100)
forward(20)
right(90)
forward(14)
pendown()
pencolor('#9c5e4a')
fillcolor('#9c5e4a')
begin_fill()
for i in range(5):
forward(15)
right(144)
end_fill()
penup()
forward(27)
left(90)
forward(16)
left(90)
forward(7)
pendown()
fillcolor('#9c5e4a')
begin_fill()
for i in range(5):
forward(10)
right(144)
end_fill()
penup()
forward(20)
right(90)
forward(5)
pendown()
fillcolor('#9c5e4a')
begin_fill()
for i in range(5):
forward(10)
right(144)
end_fill()
penup()
right(180)
forward(6)
pendown()
fillcolor('#9c5e4a')
begin_fill()
for i in range(5):
forward(10)
right(144)
end_fill()


def leftHand2():
myPosition(-112, 284)
pencolor('black')
fillcolor('#fcc6a0')
begin_fill()
right(180)
forward(31)
left(90)
for i in range(2):
circle(4, 90)
# circle(4//2,45)
for i in range(3):
right(180)
for i in range(2):
circle(4, 90)
end_fill()


def myMouth():
myPosition(-25, 200)
left(65)
fillcolor('#77332e')
begin_fill()
# circle(20)
# forward(20)
for i in range(2):
circle(25, 90)
circle(25 // 2, 90)
end_fill()


def myEyebrow(x, y):
myPosition(x, y)
pensize(18)
right(150)
forward(25)
right(90)
for i in range(1):
right(45)
dot(15)
left(55)
forward(25)
for i in range(1):
right(45)
dot(15)


def myEyelid(x, y):
myPosition(x, y)
pensize(2)
left(170)
circle(-23, 180)


def myallEyes1(x, y):
myPosition(x, y)
right(90)
fillcolor('#000000')
begin_fill()
circle(18)
end_fill()
left(90)
penup()
forward(19)
right(90)
forward(7)
pendown()
fillcolor('#ffffff')
begin_fill()
left(90)
circle(9)
end_fill()


def myallEyes2(x, y):
myPosition(x, y)
right(90)
fillcolor('#000000')
begin_fill()
circle(18)
end_fill()
left(90)
penup()
forward(19)
right(90)
forward(8)
pendown()
fillcolor('#ffffff')
begin_fill()
left(90)
circle(9)
end_fill()


def myRobot():
myPosition(155, -105)
left(93)
color('navy blue')
pensize(7)

begin_fill()
forward(50)
left(90)
forward(50)
left(90)
forward(50)
left(90)
forward(50)
left(90)
end_fill()

color('white')
penup()
left(90)
forward(30)
right(90)
forward(12)
pendown()
pensize(3)
circle(5)
penup()
forward(25)
pendown()
circle(5)

penup()
right(90)
forward(20)
right(90)
pendown()

begin_fill()
forward(23)
right(90)
forward(7)
right(90)
forward(23)
right(90)
forward(7)
right(90)
end_fill()

penup()
forward(25)
right(90)
forward(35)
pendown()

color('navy blue')
forward(30)
penup()
right(90)
pendown()
begin_fill()
circle(5)
end_fill()


def allLegs():
leftLeg()
leftSock()
leftShoe()
rightLeg()
rightSock()
rightShoe()


def allHands():
rightHand()
leftHand()
myBis()
leftHand2()


def allEyebrows():
myEyebrow(-8, 300)
right(90)
myEyebrow(72, 300)
myEyelid(-9, 270)
left(15)
myEyelid(68, 265)


def allEyes():
myallEyes1(17, 275)
myallEyes2(95, 270)


ankita()
allLegs()
myShirt()
myHead()
allHands()
myMouth()
allEyebrows()
allEyes()
myRobot()
ht()
done()

Tuesday, August 17, 2021

Indian Flag Using Python Turtle Graphics

 Indian Flag Python Turtle Graphics:


from turtle import *

# import time
s = Screen()
s.screensize(700, 1000)
speed(13)


def myPosition(x, y):
penup()
goto(x, y)
pendown()


# time.sleep(10)
# ht()
pensize(2)


def ankita():
fillcolor('#ffec40')
begin_fill()
right(25)
forward(20)
right(45)
forward(20)
left(70)
forward(90)
left(95)
forward(75)
left(85)
forward(175)
left(85)
forward(75)
left(95)
forward(90)
left(85)
forward(18)
end_fill()


def leftLeg():
myPosition(-39, -25)
fillcolor("#ffd699")
begin_fill()
right(89)
forward(25)
right(90)
forward(50)
right(90)
forward(20)
right(85)
forward(50)
end_fill()


def leftSock():
myPosition(-36, -78)
fillcolor("#ffffff")
begin_fill()
right(90)
circle(80, 13)
right(110)
forward(22)
right(85)
forward(19)
right(90)
forward(21)
end_fill()


def leftShoe():
myPosition(-69, -112)
fillcolor("black")
begin_fill()
right(90)
left(5)
forward(56)
left(105)
forward(13)
left(75)
forward(20)
right(90)
forward(15)
circle(10, 15)
left(80)
forward(4)
circle(10, 15)
left(40)
circle(20, 15)
forward(10)
right(45)
forward(15)
circle(25, 25)
end_fill()


def rightLeg():
myPosition(60, -28)
fillcolor("#ffd699")
begin_fill()
# right(90)
left(128)
forward(25)
right(95)
forward(55)
right(90)
forward(20)
right(85)
forward(55)
end_fill()


def rightSock():
myPosition(64, -79)
fillcolor("#ffffff")
begin_fill()
right(90)
circle(90, 14)
right(110)
forward(23)
right(90)
forward(15)
right(80)
forward(21)
end_fill()


def rightShoe():
myPosition(64, -108)
fillcolor("black")
begin_fill()
right(100)
forward(56)
left(160)
forward(25)
right(68)
forward(17)
left(90)
circle(18, 15)
forward(5)
left(75)
forward(11)
right(85)
forward(20)
left(45)
circle(10, 30)
left(25)
forward(5)
end_fill()


def myShirt():
myPosition(-75, 48)
fillcolor("red")
begin_fill()
left(72)
forward(185)
left(87)
forward(75)
right(68)
circle(20, 8)
circle(300, 23)
left(90)
circle(35, 17)
right(38)
circle(35, 17)
left(58)
forward(75)
right(12)
forward(140)
right(40)
forward(93)
left(120)
circle(-20, 65)
left(75)
forward(10)
left(23)
forward(88)
# circle(-80,10)
right(31)
forward(87)
right(180)
forward(108)
right(180)
forward(104)
circle(10, 70)
end_fill()


def myHead():
myPosition(-20, 295)
left(20)
pensize(2)
fillcolor('#fcc6a0')
begin_fill()
right(90)
forward(40)
right(90)
circle(50, 80)
left(10)
circle(50, 80)
left(2)
circle(200, 50)

left(48)
forward(60)
# left(20)
circle(45, 60)
right(5)
circle(100, 85)
end_fill()
fillcolor('black')
begin_fill()

pensize(2)
right(170)
circle(-100, 165)
right(78)
forward(26)
right(87)
forward(55)
circle(45, 60)
right(5)
circle(100, 85)
end_fill()

fillcolor('#fcc6a0')
begin_fill()
right(180)
circle(-100, 105)
right(37)
forward(49)
pensize(2)
left(130)
forward(30)
# right(5)
circle(-10, 70)
right(50)
# circle(10,10)
forward(36)
right(80)
forward(50)
pencolor('#fcc6a0')
right(90)
forward(30)

end_fill()


def rightHand():
# left(35)
myPosition(197, 209)
pencolor('black')
fillcolor('#fcc6a0')
begin_fill()
right(45)
forward(6)
left(55)
forward(20)
circle(-5, 70)
right(100)
forward(18)
left(105)
forward(18)
circle(-5, 70)
right(100)
forward(18)
left(145)
forward(15)
circle(-5, 70)
right(100)
forward(18)

left(150)
forward(13)
circle(-5, 70)
right(100)
forward(15)

left(150)
forward(10)
circle(-5, 70)
right(100)
forward(12)
circle(60, 10)
left(45)
forward(6)
right(90)
forward(10)
end_fill()


def leftHand():
myPosition(-94, 242)
fillcolor('#fcc6a0')
begin_fill()
right(10)
forward(6)
left(90)
penup()
forward(12)
pendown()
left(90)
forward(8)
left(90)
forward(12)
end_fill()


def myBis():
myPosition(-103, 291)
right(90)
fillcolor('#02d302')
begin_fill()
right(90)
forward(55)
left(80)
forward(12)
left(10)
forward(17)
left(10)
forward(12)
left(80)
forward(55)
left(80)
forward(12)
left(10)
forward(17)
left(10)
forward(12)
left(80)
left(80)
forward(12)
left(10)
forward(17)
left(10)
forward(12)
end_fill()
penup()
right(100)
forward(20)
right(90)
forward(14)
pendown()
pencolor('#9c5e4a')
fillcolor('#9c5e4a')
begin_fill()
for i in range(5):
forward(15)
right(144)
end_fill()
penup()
forward(27)
left(90)
forward(16)
left(90)
forward(7)
pendown()
fillcolor('#9c5e4a')
begin_fill()
for i in range(5):
forward(10)
right(144)
end_fill()
penup()
forward(20)
right(90)
forward(5)
pendown()
fillcolor('#9c5e4a')
begin_fill()
for i in range(5):
forward(10)
right(144)
end_fill()
penup()
right(180)
forward(6)
pendown()
fillcolor('#9c5e4a')
begin_fill()
for i in range(5):
forward(10)
right(144)
end_fill()


def leftHand2():
myPosition(-112, 284)
pencolor('black')
fillcolor('#fcc6a0')
begin_fill()
right(180)
forward(31)
left(90)
for i in range(2):
circle(4, 90)
# circle(4//2,45)
for i in range(3):
right(180)
for i in range(2):
circle(4, 90)
end_fill()


def myMouth():
myPosition(-25, 200)
left(65)
fillcolor('#77332e')
begin_fill()
# circle(20)
# forward(20)
for i in range(2):
circle(25, 90)
circle(25 // 2, 90)
end_fill()


def myEyebrow(x, y):
myPosition(x, y)
pensize(18)
right(150)
forward(25)
right(90)
for i in range(1):
right(45)
dot(15)
left(55)
forward(25)
for i in range(1):
right(45)
dot(15)


def myEyelid(x, y):
myPosition(x, y)
pensize(2)
left(170)
circle(-23, 180)


def myallEyes1(x, y):
myPosition(x, y)
right(90)
fillcolor('#000000')
begin_fill()
circle(18)
end_fill()
left(90)
penup()
forward(19)
right(90)
forward(7)
pendown()
fillcolor('#ffffff')
begin_fill()
left(90)
circle(9)
end_fill()


def myallEyes2(x, y):
myPosition(x, y)
right(90)
fillcolor('#000000')
begin_fill()
circle(18)
end_fill()
left(90)
penup()
forward(19)
right(90)
forward(8)
pendown()
fillcolor('#ffffff')
begin_fill()
left(90)
circle(9)
end_fill()


def myRobot():
myPosition(155, -105)
left(93)
color('navy blue')
pensize(7)

begin_fill()
forward(50)
left(90)
forward(50)
left(90)
forward(50)
left(90)
forward(50)
left(90)
end_fill()

color('white')
penup()
left(90)
forward(30)
right(90)
forward(12)
pendown()
pensize(3)
circle(5)
penup()
forward(25)
pendown()
circle(5)

penup()
right(90)
forward(20)
right(90)
pendown()

begin_fill()
forward(23)
right(90)
forward(7)
right(90)
forward(23)
right(90)
forward(7)
right(90)
end_fill()

penup()
forward(25)
right(90)
forward(35)
pendown()

color('navy blue')
forward(30)
penup()
right(90)
pendown()
begin_fill()
circle(5)
end_fill()


def allLegs():
leftLeg()
leftSock()
leftShoe()
rightLeg()
rightSock()
rightShoe()


def allHands():
rightHand()
leftHand()
myBis()
leftHand2()


def allEyebrows():
myEyebrow(-8, 300)
right(90)
myEyebrow(72, 300)
myEyelid(-9, 270)
left(15)
myEyelid(68, 265)


def allEyes():
myallEyes1(17, 275)
myallEyes2(95, 270)


ankita()
allLegs()
myShirt()
myHead()
allHands()
myMouth()
allEyebrows()
allEyes()
myRobot()
ht()
done()

Happy Birthday Priya Using Python Turtle Graphics

Happy Birthday Priya Using Python Turtle Graphics.... import  turtle  as  tech_habit from turtle import * from random import randint ankita ...