Count the positives · นับเลขบวก
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 · Functions →
English
Count the positives
Return how many numbers in a list are greater than 0. Zero itself does not count.
A counter starts at 0 and grows by 1 each time the condition is true.
ไทย
นับจำนวนเลขบวก
คืนว่าในรายการมีตัวเลขกี่ตัวที่มีค่ามากกว่า 0. ตัวเลข 0 เองไม่也算在内 (zero itself does not count).
ตัวนับเริ่มที่ 0 และเพิ่มขึ้น 1 ทุกครั้งที่เงื่อนไขเป็นจริง
Write count_positive(nums) that returns how many numbers in the list are greater than 0. · เขียน count_positive(nums) ที่ คืนค่า จำนวนเลขในรายการที่มีค่ามากกว่า 0
Click Run to see the output here. · คลิก Run เพื่อดูผลลัพธ์ที่นี่