Count up to five · นับขึ้นถึงห้า
This page needs a recent browser (with SharedArrayBuffer support). Please update Chrome, Edge, Firefox or Safari to the latest version. · หน้านี้ต้องใช้เบราว์เซอร์ล่าสุด (รองรับ SharedArrayBuffer) กรุณาอัปเดต Chrome, Edge, Firefox หรือ Safari เป็นเวอร์ชันล่าสุด
This one builds on a lesson you haven't finished yet. Do that lesson first: · อันนี้สร้างจากบทเรียนที่คุณยังไม่เสร็จสิ้น ให้ทำบทเรียนนั้นก่อน:
Python Basics · While loops · ลูป while →
English
Count up to five
Use a while loop to print 1 to 5, one per line. Start n at 1.
Counting up needs n = n + 1 instead of n - 1, and a question that stops at the right place. n <= 5 lets 5 through; n < 5 would stop one early.
ไทย
นับขึ้นถึงห้า
ใช้ลูป while เพื่อพิมพ์ 1 ถึง 5 บรรทัดละหนึ่งตัว เริ่ม n ที่ 1
การนับขึ้นต้องใช้ n = n + 1 แทน n - 1 และมีคำถามที่หยุดที่จุดที่ถูกต้อง n <= 5会让 5 ผ่าน; n < 5 จะหยุดเร็วเกินไป
Use a while loop to print 1 to 5, one per line. Start n at 1. · ใช้ลูป while เพื่อพิมพ์ 1 ถึง 5 บรรทัดละหนึ่งตัว เริ่ม n ที่ 1
Click Run to see the output here. · คลิก Run เพื่อดูผลลัพธ์ที่นี่