Skip to content

Instantly share code, notes, and snippets.

@rathankalluri
Created November 1, 2016 07:34
Show Gist options
  • Save rathankalluri/d88ee0df9bb685b01b19376f578b7998 to your computer and use it in GitHub Desktop.
Save rathankalluri/d88ee0df9bb685b01b19376f578b7998 to your computer and use it in GitHub Desktop.
Draw a Flower in Python
import turtle
""" Draw a flower in Pyhton"""
def draw_square(square):
for i in range(0,2):
square.forward(100)
square.right(30)
square.forward(100)
square.right(150)
def draw_flower():
window = turtle.Screen()
window.bgcolor("blue")
pen = turtle.Turtle()
pen.shape("triangle")
pen.color("#99FF00")
for i in range(0,36):
draw_square(pen)
pen.right(10)
for i in range(0,4):
pen.circle(50)
pen.right(90)
pen.right(90)
pen.forward(300)
pen.right(90)
draw_square(pen)
pen.left(180)
draw_square(pen)
pen.left(270)
pen.forward(200)
window.exitonclick()
draw_flower()
@clarerocks2007
Copy link

clarerocks2007 commented Oct 3, 2019

if you want colored petals use this one

import turtle

def draw_square(square):

for i in range(0,2):

	square.forward(100)

	square.right(30)

	square.forward(100)

	square.right(150)

def draw_flower():

robopen = turtle.Turtle()

robopen.shape("turtle")
robopen.color("pink")



for i in range(0,36):

	draw_square(robopen)

	robopen.right(10)



for i in range(0,4):

	robopen.circle(50)

	robopen.right(90)

robopen.right(90)


robopen.color("green")


robopen.forward(300)

robopen.right(90)

draw_square(robopen)

robopen.left(180)

draw_square(robopen)

robopen.left(270)

robopen.forward(200)

draw_flower()
turtle flower

@rathankalluri
Copy link
Author

Thanks for that @clarerocks2007

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment