Lesson goal: An Introduction to Arrays

Previous: $\sqrt{n}-\sqrt{n-1}<0.01$ | Home | Next: Loops and arrays

In a past lesson, you learned that a variable is a place that can store or hold a single quantity of information. An array is also a variable, but is different in that it can hold more than one value, all under the same variable name.

With normal variables, you can hold just one value as in score=10, in which case the variable score hold the single value of 10. With an array, you can hold many values, as you'll learn in this lesson.

First, we have to be able to tell the computer when we want a variable to be an array, and what values to hold in it. This is done like this:
variable={val1,val2,val3,val4,val5,...}
Move the mouse over a dotted box for more information.

Now you try. Fix the print statement, so that it will display the value of the 1st element in the array.

Type your code here:


See your results here: