Skip to main content
Library homepage
 

Text Color

Text Size

 

Margin Size

 

Font Type

Enable Dyslexic Font
Physics LibreTexts

28.2: Arrays

( \newcommand{\kernel}{\mathrm{null}\,}\)

It is often the case that we need to represent a series of numbers. For example, imagine that you have measured the position of an object as a function of time. Arrays are a convenient way to hold a series of numbers that are all alike, for example, all of the values of the position and corresponding time values for the trajectory of the object. In Python, we can define variables that hold arrays instead of a single value (arrays are called “lists” in Python):

python code 28.2.1

Arrays in python

1#define an array of values for the position of the object
2position = [0 ,1 ,4 ,9 ,16 ,25]
3#define an array of values for the corresponding times
4time = [0 ,1 ,2 ,3 ,4 ,5]

This page titled 28.2: Arrays is shared under a CC BY-SA 4.0 license and was authored, remixed, and/or curated by Ryan D. Martin, Emma Neary, Joshua Rinaldo, and Olivia Woodman via source content that was edited to the style and standards of the LibreTexts platform.

Support Center

How can we help?