> 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="https://1059722861-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FWAMRQLhtfzfy8yv80Se5%2Fuploads%2FDywaMArwzvz1MZ9DMWuT%2Fexam03.png?alt=media&amp;token=0e59fd5c-73eb-47ca-9cc2-667018fd5fde" alt=""><figcaption></figcaption></figure>
