ชุดคำสั่งที่ทำงานตามลำดับ
พื้นที่ฝึก
Python
เส้นทางฝึก Python ตั้งแต่ศูนย์
นิยามก่อน
Python คืออะไร
Python ใช้เขียนคำสั่งที่ชัดเจน ที่นี่เรียนเป็น เส้นทางฝึก Python ตั้งแต่ศูนย์ เริ่มจากภาพเดียว input ผ่านขั้นตอนแล้วกลายเป็น output
app.pyรัน python app.pyนิสัย เรียน Python ทีละส่วนเล็ก แล้วพิมพ์ตัวอย่างสั้นและรันค่าคือข้อมูล ตัวแปรคือชื่อที่เก็บข้อมูล
งานย่อยที่มีชื่อ รับ input และสร้างผลลัพธ์
Python 3 รันโค้ดจาก app.py
โค้ดแรกที่อ่านง่าย
Variables
names lists dictionaries stringsscore = 40 + 2 print(score)
ผลลัพธ์ 42ตระกูลภาษา
ผังตระกูล Python
ดูว่า Python มาจากไหน ใกล้กับภาษาใด และควรเรียนอะไรต่อ
เริ่มจากศูนย์
คลังคำถาม
ค้นหาก่อนฝึก
เลือกขั้นหรือค้นหาแบบฝึกของภาษานี้ แล้วเปิดข้อที่ต้องการทันที
Python ข้อ 1
Python ข้อ 1 เลือกคำอธิบายที่ตรงกับ function definition ที่สุด
Python ข้อ 2
Python ข้อ 2 เลือกคำอธิบายที่ตรงกับ list append ที่สุด
Python ข้อ 3
Python ข้อ 3 เลือกคำอธิบายที่ตรงกับ dictionary access ที่สุด
Python ข้อ 4
Python ข้อ 4 เลือกคำอธิบายที่ตรงกับ for loop ที่สุด
Python ข้อ 5
Python ข้อ 5 เลือกคำอธิบายที่ตรงกับ function definition ที่สุด
Python ข้อ 6
Python ข้อ 6 เลือกคำอธิบายที่ตรงกับ list append ที่สุด
Python ข้อ 7
Python ข้อ 7 เลือกคำอธิบายที่ตรงกับ dictionary access ที่สุด
Python ข้อ 8
Python ข้อ 8 เลือกคำอธิบายที่ตรงกับ for loop ที่สุด
Python ข้อ 9
Python ข้อ 9 เลือกคำอธิบายที่ตรงกับ function definition ที่สุด
Python ข้อ 10
Python ข้อ 10 เลือกคำอธิบายที่ตรงกับ list append ที่สุด
Python ข้อ 11
Python ข้อ 11 เลือกคำอธิบายที่ตรงกับ dictionary access ที่สุด
Python ข้อ 12
Python ข้อ 12 เลือกคำอธิบายที่ตรงกับ for loop ที่สุด
Python ข้อ 13
Python ข้อ 13 เลือกคำอธิบายที่ตรงกับ function definition ที่สุด
Python ข้อ 14
Python ข้อ 14 เลือกคำอธิบายที่ตรงกับ list append ที่สุด
Python ข้อ 15
Python ข้อ 15 เลือกคำอธิบายที่ตรงกับ dictionary access ที่สุด
Python ข้อ 16
Python ข้อ 16 เลือกคำอธิบายที่ตรงกับ for loop ที่สุด
Python ข้อ 17
Python ข้อ 17 เลือกคำอธิบายที่ตรงกับ function definition ที่สุด
Python ข้อ 18
Python ข้อ 18 เลือกคำอธิบายที่ตรงกับ list append ที่สุด
ปรนัย
Python ข้อ 1
Python ข้อ 1 เลือกคำอธิบายที่ตรงกับ function definition ที่สุด
def add(a, b):
return a + bอ้างอิง
รูปแบบของ app.py
python app.pynames lists dictionaries strings
Variables
score = 40 + 2 print(score)
- Indentation matters
- Use descriptive names
- Print intermediate values
def parameters return
ฟังก์ชัน
def add(a, b):
return a + b
print(add(2, 3))- Use def to name work
- Indent the body
- Return the result
for ranges lists dictionaries
Loops
for item in ["a", "b"]:
print(item)- Loop over values directly
- Use enumerate when index matters
- Keep loop bodies short