python drawing four leaf clover

angryTom
Release: 2020-02-14 09:37:46
Original
9258 people have browsed it

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()
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!