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

  1. Read through the following NumPy Tutorials from W3 Schools, working through the exercises in each section:

  2. Write up your answers to the following (or write a program):
    1. Write a statement to create a 1-dimensional array with 5 integer values.
    2. Write a statement to print the first element of your array.
    3. Write a statement to print the last element of your array using negative indexing.
    4. 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.)
    5. Write a statement to print the 2nd, 3rd, and 4th elements of your array by using slicing.
    6. Write a statement to print the 1st, 3rd, and 5th elements of your array by using slicing.
    7. (Optional Challenge): Write a statement that prints the elements of your array in reverse order buy using slicing.

Submit