Home >Backend Development >Python Tutorial >python drawing four leaf clover

python drawing four leaf clover

angryTom
angryTomOriginal
2020-02-14 09:37:469350browse

This article introduces how to draw a four-leaf clover in python using the turtle library. The code is very simple. I hope it will be helpful to friends who are learning python.

python drawing four leaf clover

python drawing four-leaf clover

import turtle

def draw_shapes():
    window = turtle.Screen()
    window.bgcolor("red")

    flower = turtle.Turtle()
    flower.speed(10)
    flower.shape("arrow")
    flower.right(45)
    for i in range(1,37):
        for j in range(1,5):
            draw_circle(flower,i,"green")
            flower.left(90)
    flower.right(45)
    flower.color("green")
    flower.forward(500)

    window.exitonclick()

def draw_circle(circle,radius,color):
    circle.color(color)
    circle.circle(radius)

draw_shapes()

Rendering:

python drawing four leaf clover

Many python training videos, all on the python learning network, welcome to learn online!

The above is the detailed content of python drawing four leaf clover. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Previous article:How to execute py fileNext article:How to execute py file