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 · Python 基础 · 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 本身不算。
计数器从 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. · 点击“运行”查看此处输出。