Python drawing Pakistan flag using turtle
In this blog we will draw Pakistan Flag project using turtle . We draw the simple flag using python library name as turtle.Turtle provide easy way to draw any board using turtle.
In this blog we will draw austrain project using turtle . We draw the simple flag using python library name as turtle.Turtle provide easy way to draw any board using turtle.
At the point when I was a youngster, I used to learn Logo, a programming language that elaborate a turtle that you could move around the screen with only a couple of orders. I felt like a PC virtuoso as I controlled this little article on my screen, and this got me keen on programming in any case. The Python turtle library accompanies a comparative intuitive element that provides new software engineers with a sample of what it resembles to work with Python.
In this instructional exercise, you will:
Comprehend what the Python turtle library is
Figure out how to set turtle up on your PC
Program with the Python turtle library
Embrace some significant Python ideas and turtle orders
Foster a short yet engaging game utilizing what you've realized
On the off chance that you're a fledgling to Python, this instructional exercise will assist you as you with moving into the universe of programming with the assistance of the Python turtle library!
Getting to Realize the Python turtle Library
Python Turtle projects
First we will import the turtle library in our python code.
import turtle
Now get the turtle module and then you can do any thing using turtle object.
Using turtle object you can call any method to draw dimenssion or any other lines or color.
We can use lot of function of turtle using turtle object like forword() ,backword() , Up(), down().
Code Part 1
Python Turtle projects |
Code Part 2
Python Turtle projects |
Python Turtle projects |
Code Part 4
Python Turtle projects |
Here is Output of above Code
Python Turtle projects |
Here code of above example
import turtle
wn = turtle.Screen()
wn.bgcolor("black")
turtle = turtle.Turtle()
turtle.speed(10)
turtle.penup()
turtle.shape("turtle")
def drawFillRectangle(x, y, length, width, color):
turtle.goto(x, y)
turtle.pendown()
turtle.color(color)
turtle.begin_fill()
turtle.forward(width)
turtle.right(90)
turtle.forward(length)
turtle.right(90)
turtle.forward(width)
turtle.right(90)
turtle.forward(length)
turtle.right(90)
turtle.end_fill()
turtle.penup()
def drawStar(x, y, color, length):
turtle.goto(x, y)
turtle.setheading(0)
turtle.pendown()
turtle.begin_fill()
turtle.color(color)
for turn in range(0, 5):
turtle.forward(length)
turtle.right(144)
turtle.end_fill()
turtle.penup()
def drawCircle(x, y, color, radius):
turtle.goto(x, y)
turtle.color(color)
turtle.begin_fill()
turtle.circle(radius)
turtle.end_fill()
def drawMoon(x, y, color, radius):
turtle.up()
turtle.goto(x, y)
turtle.color(color)
turtle.begin_fill()
turtle.circle(radius)
turtle.end_fill()
def drawGreen():
x = -230
y = 125
color = 'dark green'
drawFillRectangle(x, y, 280, 460, color)
def drawWhite():
x = -230
y = 125
color = 'white'
drawFillRectangle(x, y, 280, 130, color)
def Star():
x = 70
y = 30
color = 'white'
drawStar(x, y, color, 50)
def Circle():
x = 45
y = -100
color = 'white'
drawCircle(x, y, color, 80)
def Moon():
x = 65
y = -72
color = 'dark green'
drawMoon(x, y, color, 70)
drawGreen()
drawWhite()
Circle()
Moon()
Star()
turtle.goto(125, -200)
turtle.color('green')
turtle.write("PAKISTAN ZINDABAD")
0 Comments