Count down in twos · นับถอยหลังแบบสอง
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 down in twos
n starts at 10. Print 10, 8, 6, 4, 2 using a while loop.
The step does not have to be 1. Check where it stops: from 10 taking 2 each time, the value after 2 is 0, and 0 > 0 is false — so 0 is never printed.
ไทย
นับถอยหลังแบบก้าวละสอง
n เริ่มที่ 10. พิมพ์ 10, 8, 6, 4, 2 โดยใช้ลูป while
ขั้นเดิน (step) ไม่ต้องเป็น 1. ตรวจสอบว่ามันหยุดที่ไหน: จาก 10taking 2 ทุกครั้ง ค่าหลังจาก 2 คือ 0, และ 0 > 0 เป็นfalse — ดังนั้น 0 จะไม่ถูกพิมพ์เลย
n starts at 10. Print 10, 8, 6, 4, 2 using a while loop. · n เริ่มที่ 10. พิมพ์ 10, 8, 6, 4, 2 โดยใช้ลูป while
Click Run to see the output here. · คลิก Run เพื่อดูผลลัพธ์ที่นี่