> For the complete documentation index, see [llms.txt](https://krootee.gitbook.io/python-turtle/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://krootee.gitbook.io/python-turtle/1.example01-10/03..md).

# 03.วาดรูปสามเหลี่ยม

{% code title="" overflow="wrap" lineNumbers="true" fullWidth="true" %}

```python
import turtle  # นำเข้าไลบรารี turtle

t = turtle.Turtle() # สร้างวัตถุ turtle ใหม่
t.shape('turtle')   # กำหนดรูปร่างของ turtle เป็น 'turtle'

# วาดรูปสามเหลี่ยม
for i in range(3):  # ทำซ้ำ 3 ครั้งสำหรับแต่ละด้านของสามเหลี่ยม
    t.forward(100)  # เคลื่อนที่ไปข้างหน้า 100 หน่วย
    t.left(120)     # หันซ้าย 120 องศา

turtle.done()       # เสร็จสิ้นการวาดภาพและแสดงหน้าต่าง
```

{% endcode %}

<figure><img src="/files/eKLsLpsF8cMjBqBVfzcu" alt=""><figcaption></figcaption></figure>
