Your first function · 你的第一个函数
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
Your first function
Up to now you printed things. A function is a small machine: you give it an input and it returns an answer. You write the inside; the checker tries it with several inputs.
return hands the answer back. Complete double so it returns n times two.
中文
你的第一个函数
到现在为止你都在打印东西。函数是一台小机器:你给它一个输入,它就返回一个答案。你来写里面的内容;检查器会用多个输入来测试它。
return 把答案交回去。完成 double,让它返回 n 的两倍。
Write a function · 功能. Complete double(n) so it returns n times two. · 写一个函数。完成 double(n),让它返回 n 的两倍。
Click Run to see the output here. · 点击“运行”查看此处输出。