Lesson 1: First lines
หน้านี้ต้องใช้เบราว์เซอร์ล่าสุด (รองรับ SharedArrayBuffer) กรุณาอัปเดต Chrome, Edge, Firefox หรือ Safari เป็นเวอร์ชันล่าสุด
English
Meet the turtle
- In Python, a turtle is a small arrow with a pen.
- It walks on the screen and draws a line behind it.
- This is real Python: the same code works in IDLE on your computer at home.
Words for this lesson
| Word | Meaning |
|---|---|
| forward | walk ahead in the direction the turtle faces |
| left / right | turn on the spot, by an angle in degrees |
| degree | a full turn is 360 degrees; a corner of a square is 90 |
English
Walk and turn
forward(100)walks 100 steps.left(90)turns a quarter turn.- The turtle starts in the middle, looking right.
import turtle
turtle.forward(100)
turtle.left(90)
turtle.forward(50)
- Press Run: the turtle draws an L shape.
ความยาก 1/5 · 100 เหรียญ + บอนัสน้อยๆ เมื่อทำสำเร็จครั้งแรกในวันนี้
Draw a square with sides of 100 steps. The turtle must end where it started.
คลิก Run เพื่อดูผลลัพธ์ที่นี่
ความยาก 2/5 · 140 เหรียญ + บอนัสน้อยๆ เมื่อทำสำเร็จครั้งแรกในวันนี้
Draw a rectangle: 150 steps wide and 80 steps tall. End where you started.
คลิก Run เพื่อดูผลลัพธ์ที่นี่