Lists¶
- Variable stores multiple pieces of information (numbers, strings, values True or False)
- Think about your answer. If you still think the same, create these programs in Scratch and run them. Don't forget to arrange so that the values of the variables can be seen on the stage.
- Variable stores only one piece of information (a number, a string, value True or False)
- Well done! Even though they are different, the running of both programs has the same result.
Q-3: We have created the variable . At one point, the value of this variable is , and at another point, its value is . Choose the correct statement:
In the process of creating a program, programmers often have to store a lot of data (telephone numbers, names of products, addresses, etc.). In these situations, the variables we have been using so far are not very helpful.
Because of these situations, which you will surely encounter in your future programming, we present you the List.
A list is a collection of data. You can look at it as a “notebook” containing a large number of “pages”. Each “page” has a number (from 1 onward) and one piece of information is written (stored) in each of the “boxes”.
A list is created in the category Variables, by clicking on the button . A list can refer to one or all of the sprites in a program. List elements are entered by clicking on the sign + and writing values in the corresponding fields.
Unlike regular variables, which are retrieved by indicating their name, each item from a list can be retrieved “called upon” by indicating their number (position) on the list.
The list contains 5 items - text symbols depicting facial expressions. If we want the cat to say how WINKING can be depicted by using symbols, we need to make the following list:
We made the same quiz by using regular variables and by using lists. Analyze their scripts:
Remix programs A and B, which can be found at A: https://scratch.mit.edu/projects/326482978/ and B: https://scratch.mit.edu/projects/326477714/, by adding at least three questions related to feelings and emoticons that represent them. We have no doubt you will notice how much time we save by using lists instead of variables.