Welcome to the Code World! 欢迎来到代码世界!
Welcome to the Code World! 欢迎来到代码世界!
The Magic of Giving Instructions 指令的神奇魔法
你有没有想过,当你对着智能音箱说"嘿,小爱同学,播放我喜欢的歌曲"时,发生了什么?你说出的每一个字都是一条指令,而那个小小的音箱就像一个听话的魔法师,听到指令后就会帮你找到音乐并播放出来。这就是指令的魔力——用语言告诉机器该做什么。
Have you ever wondered what happens when you say "Hey, Alexa, play my favorite song" to a smart speaker? Every word you speak is an instruction, and that little device is like a obedient magician—it hears your command and finds the music to play for you. This is the magic of instructions—using language to tell machines what to do!
其实,你每天都在和"指令"打交道,只是从来没有这样想过。想象一下,你早上起床,脑子里会有一个"待办清单":刷牙、洗脸、吃早餐、背书包、出门上学。这个清单就是一个算法(Algorithm)——一步一步告诉你要做什么的指令列表。算法就是解决某个问题或完成某项任务的具体步骤和方法。
Actually, you deal with "instructions" every single day, you just never thought about it this way. Imagine you wake up in the morning with a mental "to-do list": brush your teeth, wash your face, eat breakfast, grab your backpack, go to school. This list is an algorithm—a step-by-step list of instructions telling you what to do. An algorithm is a specific set of steps and methods to solve a problem or complete a task.
Code is Just Super Specific Instructions 代码就是超级具体的指令
现在让我们把"刷牙"这件事想得更仔细一点。刷牙看起来是一件简单的事,但如果我们要把它写成一条指令让一个机器人来做,会是什么样子呢?
Now let's think more carefully about "brushing teeth." Brushing teeth seems like a simple thing, but what would it look like if we had to write it as an instruction for a robot to do?
```mermaid graph TD A[拿起牙刷] --> B[打开牙膏盖子] B --> C[把牙膏挤到牙刷上] C --> D[打开水龙头] D --> E[把牙刷浸湿] E --> F[把牙刷放进嘴里] F --> G[上下刷动 30 次] G --> H[漱口] H --> I[清洗牙刷] I --> J[把牙刷放回杯子里] ```
看!一件我们每天不知不觉就完成的事情,拆解开来竟然有这么多步骤。而且,每一个步骤还必须描述得非常清楚——"挤牙膏"要挤多少?"上下刷动"要刷多久?左边的牙和右边的牙都要刷吗?
Look! Something we complete every day without even thinking about it actually has so many steps when we break it down. And every single step needs to be described very clearly—how much toothpaste should we squeeze out? How long should we brush? Do we brush the left teeth and right teeth too?
这就是编程(Programming)的本质:把我们要做的事情,用一种计算机能够理解的语言,写成一条一条具体的指令。计算机会像一个非常认真但也非常 literal(字面理解)的小朋友一样,完完全全按照你写的指令来执行。如果你写的指令有一点点不清楚或者有错误,计算机就会"困惑",程序就不会正常运行。
This is the essence of programming: taking what we want to do and writing it out as specific instructions in a language that computers can understand. The computer acts like a very serious but also very literal child—it executes your instructions exactly as written. If your instructions are even slightly unclear or have an error, the computer will become "confused" and the program won't run properly.
这就是为什么编程需要我们特别仔细和耐心。每一个细节都很重要,每一个步骤都要说得清清楚楚。但别担心——一旦你学会了如何正确地给计算机下指令,你就能让它帮你做各种各样神奇的事情!让我们一起踏上这段编程大冒险吧!
That's why programming requires us to be especially careful and patient. Every detail matters, every step needs to be crystal clear. But don't worry—once you learn how to give computers the right instructions, you can make it do all kinds of amazing things! Let's embark on this programming adventure together!
Meet Your Guides: Scratch Cat and Python Turtle 认识你的向导: Scratch 猫和 Python 小蛇
在接下来的旅程中,你不是一个人。有两位超级可爱的小伙伴会一直陪伴着你,他们就是 Scratch 猫和 Python 小蛇!
On this journey ahead, you're not alone. Two super cute friends will be with you every step of the way—Scratch Cat and Python Turtle!
Scratch Cat — 图形化编程的好朋友 Scratch Cat — Your Block-Based Coding Buddy
Scratch 猫是一只来自麻省理工学院(MIT)媒体实验室的明星猫咪。它是 Scratch 编程语言的吉祥物。Scratch 是专为编程初学者设计的,特别是像你这样的年轻学习者。
Scratch Cat is a superstar cat from MIT Media Lab. It's the mascot of the Scratch programming language. Scratch was designed specifically for beginning programmers, especially young learners like you.
Scratch 的特别之处在于,它使用的是积木式编程(Block-based Programming)。你不需要记住复杂的命令,只需要把不同颜色、不同形状的积木块拖拽到一起,就像搭乐高一样!这些积木块会告诉计算机该做什么,而且它们只能以合法的方式组合在一起,这样就大大减少了犯错的可能。
What makes Scratch special is its block-based programming. You don't need to memorize complex commands—just drag and snap together different colored, shaped blocks, just like building with LEGO! These blocks tell the computer what to do, and they can only combine in legal ways, which greatly reduces the chance of making mistakes.
Scratch Cat is orange and has a big smile. It loves to dance, tell stories, and create games. With Scratch Cat as your guide, you'll learn programming concepts while having fun making animations and simple games!
Python Turtle — 文字编程的小助手 Python Turtle — Your Text-Based Coding Assistant
Python 小蛇是一只聪明又友善的绿色小蛇。它会带着你一起学习文字编程(Text-based Programming)——也就是用键盘敲写代码。
Python Turtle is a smart and friendly little green turtle. It'll guide you through text-based programming—typing out code with your keyboard.
Python Turtle 是 Python 编程语言的一个经典模块(Module)。Python 是一种真正被全世界程序员使用的专业编程语言,而 Python Turtle 是专门设计来帮助初学者学习的工具。当你输入代码让小蛇在屏幕上移动、画图时,你其实在学习 Python 编程的基础知识!
Python Turtle is a classic module of the Python programming language. Python is a professional programming language actually used by programmers worldwide, and Python Turtle is a tool specifically designed to help beginners learn. When you type code to make the turtle move and draw on the screen, you're actually learning the fundamentals of Python programming!
Python 小蛇背上背着一个彩色的小房子,走到哪儿画到哪儿,特别喜欢画各种几何图形和有趣的图案。你会惊讶地发现,通过几个简单的指令,你就能画出正方形、三角形,甚至漂亮的彩虹!
Python Turtle carries a colorful little house on its back and draws wherever it goes. It especially loves drawing all kinds of geometric shapes and interesting patterns. You'll be amazed to discover that with just a few simple instructions, you can draw squares, triangles, and even beautiful rainbows!
Setting Up Your Scratch World 搭建你的 Scratch 世界
现在,让我们开始准备你的编程工具箱!首先,我们来安装 Scratch。
Now, let's start preparing your programming toolbox! First, let's install Scratch.
How to Get Scratch 如何获取 Scratch
Scratch 有两种使用方式,你可以选择最适合你的那一种:
Scratch has two ways to use it, and you can choose whichever works best for you:
方式一:在线使用(推荐)Online Use (Recommended)
1. 打开你的电脑浏览器(Chrome、Safari、Edge 等) 2. 在地址栏输入:scratch.mit.edu 3. 点击页面上的"创建"(Create)按钮 4. 你就可以开始编程啦!
1. Open your computer's web browser (Chrome, Safari, Edge, etc.) 2. Type scratch.mit.edu in the address bar 3. Click the "Create" button on the page 4. You can start coding!
方式二:离线下载 Offline Download
如果你想在没有网络的地方使用 Scratch,可以下载离线编辑器:
If you want to use Scratch where there's no internet, you can download the offline editor:
1. 访问 scratch.mit.edu/download 2. 选择适合你电脑系统的版本(Windows 或 Mac) 3. 下载并安装 Scratch Desktop 4. 双击图标就可以开始使用啦!
1. Visit scratch.mit.edu/download 2. Choose the version for your computer system (Windows or Mac) 3. Download and install Scratch Desktop 4. Double-click the icon to start using it!
Exploring the Scratch Interface 探索 Scratch 界面
当你打开 Scratch,你会看到一个五彩缤纷的界面。让我们一起来认识它的各个部分!
When you open Scratch, you'll see a colorful interface. Let's get to know each part of it!
```mermaid graph TD A[Scratch 界面] --> B[舞台区 Stage Area] A --> C[角色区 Sprite List] A --> D[积木区 Blocks Area] A --> E[脚本区 Scripts Area]
B --> B1[角色在这里表演<br/>可以看到程序运行效果] C --> C1[所有角色都在这里<br/>可以添加新角色] D --> D1[各种指令积木<br/>按类别分组] E --> E1[把积木拖到这里<br/>组合成程序] ```
舞台区(Stage Area) — 这是你角色的"舞台",就像剧院里的舞台一样。角色的表演就在这里展现。你可以在这里看到小猫跳舞、精灵飞翔、小球弹跳等等。舞台的背景也可以更换哦!
Stage Area — This is where your sprites "perform." Just like a stage in a theater, your characters' performances happen here. You can see the cat dancing, sprites flying, balls bouncing, and more. You can also change the stage's backdrop!
角色区(Sprite List) — 这里列出了你所有的角色(Sprite)。刚打开 Scratch 时,你通常会看到一只橙色的小猫——那就是 Scratch 猫!点击角色,你可以选择它、修改它,或者添加更多新角色。
Sprite List — This shows all your characters (sprites). When you first open Scratch, you'll usually see an orange cat—that's Scratch Cat! Click on a sprite to select it, modify it, or add more new sprites.
积木区(Blocks Area) — 这是 Scratch 最有意思的部分!这里有各种颜色的积木,每个积木都是一条指令。左边的区域有不同类别的积木分组:
Blocks Area — This is the most interesting part of Scratch! There are blocks of various colors, and each block is an ins