Upside-down triangle · 倒三角形
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 基础 · Counting loops · 计数循环 →
English
Upside-down triangle
Print four rows of stars, starting with four and ending with one.
range counts backwards with a negative step: range(3, 0, -1) gives 3, 2, 1. It still stops before its second number, which is why the stop value is 0.
中文
倒三角形
打印四行星星,从四颗开始,到一颗结束。
range 用负数步长就能倒着数:range(3, 0, -1) 给出 3、2、1。它仍然在第二个数之前停下,所以终止值写 0。
Print a triangle of stars that shrinks: ****, then ***, then **, then *. · 打印一个逐行变小的星星三角形:****、***、**、*。
Click Run to see the output here. · 点击“运行”查看此处输出。