Introduction to Arrays
Introduction
The purpose of this mini-lab is to practice creating and working with
arrays by introducing the NumPy module in Python.
Exercises
- Read through the following NumPy Tutorials from W3 Schools, working through the
exercises in each section:
- Write up your answers to the following (or write a program):
- Write a statement to create a 1-dimensional array with 5 integer
values.
- Write a statement to print the first element of your array.
- Write a statement to print the last element of your array using
negative indexing.
- Write a statement to print the last element of your array using
the
len
function. (Note:
len(arr)
returns the number of elements in the array
named arr
.)
- Write a statement to print the 2nd, 3rd,
and 4th elements of your array by using slicing.
- Write a statement to print the 1st, 3rd,
and 5th elements of your array by using slicing.
- (Optional Challenge): Write a statement that
prints the elements of your array in reverse order buy using
slicing.
Submit
When you are satisfied with your statements, make sure
your name is on your file, and then submit the file you created for this mini-lab via
Kit.