Log In

Assignment 2 - Numpy Array Operations

Open In Colab

The objective of this assignment is to develop a solid understanding of Numpy array operations. In this assignment you will:

  1. Pick 5 interesting Numpy array functions by going through the documentation: https://numpy.org/doc/stable/reference/routines.html
  2. Run and modify this Jupyter notebook to illustrate their usage (some explanation and 3 examples for each function). Use your imagination to come up with interesting and unique examples.
  3. To save your work, select "File" > "Save a Copy in Drive" on Google Colab. Once the copy is created, click the "Share" button and select "Anyone with the link" under the "General Access" section to make this notebook publicly accessible.
  4. Copy the public notebook link and submit it on the assignment page.

Try to give your notebook a catchy title & subtitle e.g. "All about Numpy array operations", "5 Numpy functions you didn't know you needed", "A beginner's guide to broadcasting in Numpy", "Interesting ways to create Numpy arrays", "Trigonometic functions in Numpy", "How to use Python for Linear Algebra" etc.

NOTE: Remove this block of explanation text before submitting or sharing your notebook online - to make it more presentable.

Title Here

Subtitle Here

Write a short introduction about Numpy and list the chosen functions.

  • function 1
  • function 2
  • function 3
  • function 4
  • function 5

This tutorial is an executable Jupyter notebook. Click the Open in Colab button at the top of this page to execute the code.

Jupyter Notebooks: This notebook is made of cells. Each cell can contain code written in Python or explanations in plain English. You can execute code cells and view the results instantly within the notebook. Jupyter is a powerful platform for experimentation and analysis. Don't be afraid to mess around with the code & break things - you'll learn a lot by encountering and fixing errors. You can use the "Kernel > Restart & Clear Output" menu option to clear all outputs and start again from the top.

Let's begin by importing Numpy and listing out the functions covered in this notebook.

import numpy as np
# List of functions explained 
function1 = np.concatenate  # (change this)
function2 = ???
function3 = ???
function4 = ???
function5 = ???

Function 1 - np.concatenate (change this)

Add some explanation about the function in your own words

# Example 1 - working (change this)
arr1 = [[1, 2], 
        [3, 4.]]

arr2 = [[5, 6, 7], 
        [8, 9, 10]]

np.concatenate((arr1, arr2), axis=1)
array([[ 1.,  2.,  5.,  6.,  7.],
       [ 3.,  4.,  8.,  9., 10.]])

Explanation about example

# Example 2 - working
???

Explanation about example

# Example 3 - breaking (to illustrate when it breaks)
arr1 = [[1, 2], 
        [3, 4.]]

arr2 = [[5, 6, 7], 
        [8, 9, 10]]

np.concatenate((arr1, arr2), axis=0)
--------------------------------------------------------------------------- ValueError Traceback (most recent call last) <ipython-input-15-3386a3db1c34> in <module> 6 [8, 9, 10]] 7 ----> 8 np.concatenate((arr1, arr2), axis=0) <__array_function__ internals> in concatenate(*args, **kwargs) ValueError: all the input array dimensions for the concatenation axis must match exactly, but along dimension 1, the array at index 0 has size 2 and the array at index 1 has size 3

Explanation about example (why it breaks and how to fix it)

Some closing comments about when to use this function.

Function 2 - ???

Add some explanations

# Example 1 - working
???

Explanation about example

# Example 2 - working
???

Explanation about example

# Example 3 - breaking (to illustrate when it breaks)
???

Explanation about example (why it breaks and how to fix it)

Some closing comments about when to use this function.

Function 3 - ???

Add some explanations

# Example 1 - working
???

Explanation about example

# Example 2 - working
???

Explanation about example

# Example 3 - breaking (to illustrate when it breaks)
???

Explanation about example (why it breaks and how to fix it)

Some closing comments about when to use this function.

Function 3 - ???

Add some explanations

# Example 1 - working
???

Explanation about example

# Example 2 - working
???

Explanation about example

# Example 3 - breaking (to illustrate when it breaks)
???

Explanation about example (why it breaks and how to fix it)

Some closing comments about when to use this function.

Function 4 - ???

Add some explanations

# Example 1 - working
???

Explanation about example

# Example 2 - working
???

Explanation about example

# Example 3 - breaking (to illustrate when it breaks)
???

Explanation about example (why it breaks and how to fix it)

Some closing comments about when to use this function.

Function 5 - ???

Add some explanations

# Example 1 - working
???

Explanation about example

# Example 2 - working
???

Explanation about example

# Example 3 - breaking (to illustrate when it breaks)
???

Explanation about example (why it breaks and how to fix it)

Some closing comments about when to use this function.

Conclusion

Summarize what was covered in this notebook, and where to go next

Provide links to your references and other interesting articles about Numpy arrays: