列表简介
-
先修科目
什么是列表?
大家已经知道如何把变量当作盒子来存放一些数字或者文字。当你要处理一系列值,比如全部同学的年龄,那就要用“列表”。
列表就是一排盒子,每个盒子都有一个不同的位置编号(标记)。
https://cdncreaticodecom.b-cdn.net/scratch-gui-projects/forum/13e9b7c2-3a06-47f2-ad28-16b741638fa7.gif" width="500" style="">
因为全部盒子看起来一样的,我们需要用位置索引号来引用盒子。比如,你可以说“处于位置2的盒子放着数字8”。
新建列表
新建列表方法:进入“变量”类别,然后点击“建立一个列表”。
https://cdncreaticodecom.b-cdn.net/scratch-gui-projects/forum/1ee29aa0-705a-433a-9bee-56624b271dec.gif" width="885" style="">
重命名列表、删除列表
其中的步骤类似于重命名变量、删除变量。
https://cdncreaticodecom.b-cdn.net/scratch-gui-projects/forum/08a981b3-0650-4244-8125-86ffcf0782c5.gif" width="997" style="">
显示列表、隐藏列表
https://cdncreaticodecom.b-cdn.net/scratch-gui-projects/forum/85b0ecef-3b8e-4c4a-869c-298a4be3c692.gif" width="997" style="">
向列表添加空项
默认情况下,新列表中没有列表项(槽)。你可以点击列表左下角的按钮“+”来添加空项。“长度”表示列表中有多少个项,也就是这个列表能存放多少个值。
https://cdncreaticodecom.b-cdn.net/scratch-gui-projects/forum/7293deac-ab22-456a-b964-6458a8c9c429.gif" width="172" style="">
删除列表项
可以选中任意一个列表项,右边有一个小小的“x”,点击即可删除该项。
https://cdncreaticodecom.b-cdn.net/scratch-gui-projects/forum/7f2817e3-340e-44d7-b0c8-d0f0d108a7a5.gif" width="172" style="">
加入数据
你可以在任意一个列表项中输入数字或文字。当你按回车键,当前项下面会新增一个空项,这样便于输入大量值。
https://cdncreaticodecom.b-cdn.net/scratch-gui-projects/forum/698298a2-01a5-4f7e-a6aa-cb063879c72b.gif" width="297" style="">
注意:当你保存项目时,列表中的数据也会被一并保存。所以下次你打开这个项目,这个列表还放着同样的数据。
继续学习
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login