0% found this document useful (0 votes)
18 views3 pages

04 Arrays 2f2e04b4c0fe

The document discusses arrays and how they allow storing multiple variables together. It provides an example of using an array to store different fruits purchased from the market. The array is defined and then each item in the array is accessed using its index to assign different values or commands. Code examples are given in Python and JavaScript to demonstrate working with arrays.

Uploaded by

Zsombor Film
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
18 views3 pages

04 Arrays 2f2e04b4c0fe

The document discusses arrays and how they allow storing multiple variables together. It provides an example of using an array to store different fruits purchased from the market. The array is defined and then each item in the array is accessed using its index to assign different values or commands. Code examples are given in Python and JavaScript to demonstrate working with arrays.

Uploaded by

Zsombor Film
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Now let's continue to our document for better understanding of our subject.

Subject: Arrays
Commands to be Used
Overview
Commands which are used with the array in the form of turtle[1].forward() and the
In our new lesson, our users will learn arrays with the ability to keep
commands which has been learned before.
multiple variables within them. Intended purpose of the arrays is that they have the
feature of keeping multiple variables at the same time within them. When we say Blocks and Button icons to be used in the training about this subject
multiple numbers it can also be big values such as 100 or 1000. Instead of declaring
a large number of variables with the same name one by one, we can keep them
together by means of arrays.
Block Explanation
When we have one variable, array and variables may be considered as the
same thing, but we shouldn't use variables instead of arrays for multiple variables. Arrays which can keep multiple variables
within them enable us to assign
Activity separate tasks for each of our characters
Let's start to understand arrays by giving an example of the fruits after in case there are multiple characters
having the same name in our task
shopping from the market. Suppose that we bought 5 different fruits. Apple,
scenes. We can transfer our characters
Banana, Orange, Apricot and Peach. Let's call all of these "Fruits". We transferred Text into an array with their common names
multiple values into the “Volunteers” variable distinctly from variable samples we and recall our characters according to
made in our previous lesson. Because of keeping multiple variables within it, the numbers we gave.
"Volunteers" became an array. Items within this array have different values but
have a common name. Now let's give some commands respectively to the items of Sample usage (Python):
myTurtles = [turtle0,turtle1]
the array that we formed for you to comprehend this better.
myTurtles [0].forward(3)



First item of the “Fruits" array is “Apple”
Second item of the “Fruits" array is “Banana”
Third item of the “Fruits" array is “Orange”
[] myTurtles [1].forward(3)
forward(5)

Sample usage (Javascript):


 Fourth item of the “Fruits" array is “Apricot”
var myTurtles = [turtle0,turtle1]
 Fifth item of the “Fruits" array is “Peach” myTurtles [0].forward(3)
myTurtles [1].forward(3)
In this manner, we can differentiate the variables belonging to the same forward(5)
type thanks to the naming we use. By virtue of the array we use, we could keep
multiple variables of a type together and assign them different values.
WARNING
We can do this activity by coding as below.
The numbering of arrays starts with 0 (zero). It means the number of the first
Fruits = [Apple, Banana, Orange, Apricot, Peach] variable is 0, the number of the second variable is 1.

codementum.com
BLOCK Erraneous writing forms
Usage Explanation

Common name of variables in array Python

1.The order of the variable

2.The order of the variable


Why is it wrong? Why is it wrong? Correct form:
Array definition In order to recall the When we want to assign Our command is correct,
3.The order of the variable items in the arrays, we our characters special because our numbers to
must write their tasks we must put a point reach array items are
1. order of the variable numbers inside square between them while within square brackets and
brackets. writing the tasks with point is used after
“[]” (Alt Gr 8-9) their names. character names when task
is written.
PYTHON
Usage Explanation
JAVASCRIPT
Array definition
Usage Explanation
The order of the variable in the array
değer Array definition

The order of the variable in the array


değer

codementum.com
Erraneous writing forms

JavaScript

Sample Solution: Scene 33

Algorithm Block Python Javascript

 Start myTurtles = [turtle0,turtle1,turtle2,turtle3] var myTurtles = [turtle0,turtle1,turtle2,turtle3]


 define the array with the name myTurtles[0].forward(3) myTurtles[0].forward(3)
“myTurtles” myTurtles[1].forward(3) myTurtles[1].forward(3)
myTurtles[2].forward(2) myTurtles[2].forward(2)
 assign the variables to “myTurtles”
myTurtles[3].forward(2) myTurtles[3].forward(2)
array [turtle0, turtle1, turtle2, forward(7) forward(7)
turtle3]
 First [0] turtle move 3 squares
forward
 Second[1] turtle move 3 squares
forward
 Third [2] turtle move 3 squares
forward
 Forth [3] turtle move 3 squares
forward
 Main character move 7 squares
forward

codementum.com

You might also like