Home > Problem, Projects/Experiments, Python > Python Project

Python Project




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
  1. No comments yet.
  1. December 6, 2018 at 9:03 am

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s