Archive

Archive for December 3, 2018

Python Project

December 3, 2018 1 comment



Python: Draw Flower

Drawing with Python

One of my favorite areas is drawing, and when its come to programming languages, one of the first thing i look after is the commands that let me draw lines and shapes.

In python, we have to import a library to help us in this task, here in this short code block I am using codes to draw a flower shape. We can improve the idea later but i want the first version to be as simple as i can. So lets see the code.


# We have to import this library
import turtle

# Here are some setting
t = turtle.Turtle()
t.shape(“point”)
t.color(‘black’)
t.speed(9)
t.left(0)
t.penup
size=10
#This function to draw one petal
def petal():

t.pendown()

for x in range (40):

t.forward(size)

t.left(x)

t.penup()

left_d=-15

for pet in range (8):

petal()

t.goto(0,0)

t.left(-15)

———————————————–

Advertisements