Fundamentals 2 min read

Drawing a Five-Pointed Star with Python Turtle

This short tutorial demonstrates how to use Python's turtle library to draw a red five‑pointed star by setting the fill color, looping five times, moving forward, and turning 144 degrees, with a complete code example and the resulting graphic.

Python Programming Learning Circle
Python Programming Learning Circle
Python Programming Learning Circle
Drawing a Five-Pointed Star with Python Turtle

This article shares a simple Python example that draws a red five‑pointed star using the turtle graphics library. It explains each step, including setting the fill color, beginning the fill, looping five times to move forward and turn, and completing the fill.

Below is the full code used to generate the star:

<code>import turtle    # 导入turtle库包

turtle.fillcolor("red")       # 填充颜色
turtle.begin_fill()              # 开始画,类似起笔

count = 1                        # 计时器,用于计录次数

while count <= 5:                # 控制绘制次数
    turtle.forward(100)       # 画笔绘制的方向,向前移动指定的距离
    turtle.right(144)       # 向右转144度
    count += 1                   # 循环绘制

turtle.end_fill()                # 完成填充图片的绘制。
</code>

The resulting image is a red star, as shown in the accompanying GIF. Readers are encouraged to try the code, modify parameters, and explore further turtle graphics techniques.

graphicsPythontutorialturtlestar-drawing
Python Programming Learning Circle
Written by

Python Programming Learning Circle

A global community of Chinese Python developers offering technical articles, columns, original video tutorials, and problem sets. Topics include web full‑stack development, web scraping, data analysis, natural language processing, image processing, machine learning, automated testing, DevOps automation, and big data.

0 followers
Reader feedback

How this landed with the community

login Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.