A list of squares · 平方数列表
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 基础 · Lists (1-D arrays) · 列表(一维数组) →
English
A list of squares
Build a list one item at a time instead of printing each value.
squares.append(x) adds x to the end of the list. Printing a whole list shows it in square brackets, with commas between the items.
中文
平方数列表
一次加入一个元素来建立列表,而不是逐个打印数值。
squares.append(x) 把 x 加到列表末尾。打印整个列表时,会用方括号显示,元素之间用逗号隔开。
Start with an empty list, add the squares of 1 to · 到 5 with .append(), then print the list. It should show [1, 4, 9, 16, 25]. · 从一个空列表开始,用 .append() 加入 1 到 5 的平方,然后打印这个列表。结果应该是 [1, 4, 9, 16, 25]。
Click Run to see the output here. · 点击“运行”查看此处输出。