Run it! · 运行起来!
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 至最新版本。
English
Start here
- A lesson is a list of short steps. Press Continue (the arrow at the bottom) for the next one.
- After the steps come tasks: code you change and run.
- Today you type very little. You change one small thing at a time.
中文
从这里开始
- 每节课由一些简短的步骤组成。按继续(页面底部的箭头)进入下一步。
- 步骤之后是任务:你要修改并运行的代码。
- 今天你几乎不用打字,每次只改一个小地方。
English
The buttons
- Run ▶ runs the code. What it prints appears in the dark box under it.
- Check answer tests your code. Green means correct, and you win coins.
- The lightbulb gives a hint when you are stuck.
- Reset brings the starting code back.
中文
这些按钮
- 运行 ▶ 执行代码。打印出的内容会显示在代码下面的深色方框里。
- 检查答案 测试你的代码。变成绿色就是正确,你还会赢得金币。
- 卡住的时候,按灯泡获取提示。
- 重置 把代码恢复成一开始的样子。
print("I am an example. Press the play button to run me.")
English
When something goes wrong
- If the code has a mistake, Python stops and shows red text.
- Under the red text, a card explains the error in English and Chinese and tells you which line to look at.
- Mistakes are normal. Read the card, fix one thing, and run again.
中文
出错的时候
- 如果代码有错误,Python 会停下来,显示红色文字。
- 红色文字下面有一张卡片,用英文和中文解释这个错误,并告诉你该看哪一行。
- 出错很正常。读一读卡片,改一个地方,再运行一次。
English
When a program waits for you
- Some programs ask a question with
input(). - Then a highlighted box appears: type here, then press Enter.
- Click the box, type your answer and press Enter. The program continues.
中文
程序等你输入的时候
- 有些程序会用
input()向你提问。 - 这时会出现一个高亮的方框:在这里输入,然后按回车。
- 点一下方框,输入你的回答,再按回车键,程序就会继续运行。
name = input("What is your name? ")
print("Nice to meet you, " + name)
English
Now you try
- Three small tasks. Change the code, press Run, then Check answer.
中文
现在轮到你
- 三个小任务。修改代码,按运行,再按检查答案。
This program is switched off: the # at the start makes the line a comment, so Python skips it. Delete the #, press Run ▶ to see what it prints, then press Check answer. · 这个程序被“关掉”了:行首的 # 把这一行变成了注释,Python 会跳过它。删掉 #,按运行 ▶ 看看它打印什么,然后按检查答案。
Click Run to see the output here. · 点击“运行”查看此处输出。
Change one word so the program prints I like dogs. Only the text inside the quotes changes. · 只改一个单词,让程序打印 I like dogs。只需要改引号里面的文字。
Click Run to see the output here. · 点击“运行”查看此处输出。
This program has a mistake. Press Run ▶ first and read the card under the red text: it explains the error. Then fix the line so the program prints Hello. · 这个程序有一个错误。先按运行 ▶,读一读红色文字下面的卡片:它会解释这个错误。然后改好这一行,让程序打印 Hello。
Click Run to see the output here. · 点击“运行”查看此处输出。