PDE - What is a List? An Array? (Lesson)
A List or an Array
Introduction
Actually a list and an array are used synonymously. We will be using them to mean the same thing, a group of items related in some way.
Have you ever....?
- woke up in the morning and your mind starts going through the items you need to do this day.
- contributed to possibly the groceries that your family needed.
- used calendar of appointments.
- used calendar of due items for the day.
- used a schedule for Monday through Friday of what to do when.
- filled out an online survey online.
- been in one or more school classes.
- used a rubric.
- counted numbers.
Do you identify with at least one or more of these above? So what is the form of the lists above? The numbers correspond to the items in the list above.
- In your mind, a mental list, possibly with times of the day.
- Groceries to buy, possibly a list on paper or in a phone memo.
- Appointments in a formal paper calendar or an online calendar, list of items by calendar day.
- School calendar that changes if a date is moved with automatic synchronization, list of items due each day.
- Family schedule for work, school, with differences on some days, list to remember items that are different especially.
- Online form, creates a group of answers by topic question, a listing of all of the answers.
- Being in school puts you on a class list, a finer list than a school list.
- A rubric, items that are needed for the best grade.
- Counting numbers in order, a verbal list.
We are all familiar with lists. Maybe we haven't thought about the relationship of the items on the list before, but a list always has a relationship in some manner. Items on your lists that you create as suggested above are information, data, that is related to the list functionality. The data on the grocery list is each item that you wish to buy.
If the list is in alphabetical order, then you name usually falls at a specific spot or area in the list. Some of you easily identify by knowing you will be at the front of a class list or the end of the list because of your last name. Others know that they in the middle, or towards the front or end.
You are a student on the list. With computers the items on the list are referred to as objects. An array or list is a grouping of objects related in some form. In the classroom you are one of many objects on the classroom list. Accessing the list depending on how the objects are related as well as how the objects are to be found. In school, your teacher may find you using your name, and at other times using your school identification number, a unique way of finding you across the complete school in case someone else has the exact name you do. Wondering if this has happened, yes it has.
Note the list in code is also called an array. An array is a grouping of numbers, textStrings, and objects. The array in Alice is a fixed length array, meaning that the length of the array will not change by adding and removing items. Once you create the array with the variable, you must add in the number of items that you will possibly be using. Creation of the array may leave room for additions or not.
When a programmer removes an item from the array, the data in the array should change back to a default value which the programmer can evaluate for validity use during a program run.
We will discuss more about the another type of array as we work in a later module on the College Board Language. You received this language document earlier as we started the second semester. You will find it included here on the PDE Resource page.
IMAGE CREATED BY GAVS.