Contents

Python NumPy For Your Grandma - 5.4 Challenge: Prime Locations

Setup

Given a 10x10x10 array of zeros, set (i,j,k) = 1 if: i is odd, j is even, and k is prime. In other words, set these elements to 1: (1,0,2), (1,0,3), (1,0,5), (1,0,7), (1,2,2), …

import numpy as np

chewy = np.zeros((10,10,10))
print(chewy)
## [[[0. 0. 0. 0. 0. 0. 0. 0. 0. 0.]
##   [0. 0. 0. 0. 0. 0. 0. 0. 0. 0.]
##   [0. 0. 0. 0. 0. 0. 0. 0. 0. 0.]
##   [0. 0. 0. 0. 0. 0. 0. 0. 0. 0.]
##   [0. 0. 0. 0. 0. 0. 0. 0. 0. 0.]
##   [0. 0. 0. 0. 0. 0. 0. 0. 0. 0.]
##   [0. 0. 0. 0. 0. 0. 0. 0. 0. 0.]
##   [0. 0. 0. 0. 0. 0. 0. 0. 0. 0.]
##   [0. 0. 0. 0. 0. 0. 0. 0. 0. 0.]
##   [0. 0. 0. 0. 0. 0. 0. 0. 0. 0.]]
## 
##  [[0. 0. 0. 0. 0. 0. 0. 0. 0. 0.]
##   [0. 0. 0. 0. 0. 0. 0. 0. 0. 0.]
##   [0. 0. 0. 0. 0. 0. 0. 0. 0. 0.]
##   [0. 0. 0. 0. 0. 0. 0. 0. 0. 0.]
##   [0. 0. 0. 0. 0. 0. 0. 0. 0. 0.]
##   [0. 0. 0. 0. 0. 0. 0. 0. 0. 0.]
##   [0. 0. 0. 0. 0. 0. 0. 0. 0. 0.]
##   [0. 0. 0. 0. 0. 0. 0. 0. 0. 0.]
##   [0. 0. 0. 0. 0. 0. 0. 0. 0. 0.]
##   [0. 0. 0. 0. 0. 0. 0. 0. 0. 0.]]
## 
##  [[0. 0. 0. 0. 0. 0. 0. 0. 0. 0.]
##   [0. 0. 0. 0. 0. 0. 0. 0. 0. 0.]
##   [0. 0. 0. 0. 0. 0. 0. 0. 0. 0.]
##   [0. 0. 0. 0. 0. 0. 0. 0. 0. 0.]
##   [0. 0. 0. 0. 0. 0. 0. 0. 0. 0.]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 0. 0. 0. 0. 0. 0. 0.]
##   [0. 0. 0. 0. 0. 0. 0. 0. 0. 0.]
##   [0. 0. 0. 0. 0. 0. 0. 0. 0. 0.]
##   [0. 0. 0. 0. 0. 0. 0. 0. 0. 0.]
##   [0. 0. 0. 0. 0. 0. 0. 0. 0. 0.]
##   [0. 0. 0. 0. 0. 0. 0. 0. 0. 0.]]
## 
##  [[0. 0. 0. 0. 0. 0. 0. 0. 0. 0.]
##   [0. 0. 0. 0. 0. 0. 0. 0. 0. 0.]
##   [0. 0. 0. 0. 0. 0. 0. 0. 0. 0.]
##   [0. 0. 0. 0. 0. 0. 0. 0. 0. 0.]
##   [0. 0. 0. 0. 0. 0. 0. 0. 0. 0.]
##   [0. 0. 0. 0. 0. 0. 0. 0. 0. 0.]
##   [0. 0. 0. 0. 0. 0. 0. 0. 0. 0.]
##   [0. 0. 0. 0. 0. 0. 0. 0. 0. 0.]
##   [0. 0. 0. 0. 0. 0. 0. 0. 0. 0.]
##   [0. 0. 0. 0. 0. 0. 0. 0. 0. 0.]]]

Solution 1

i = np.array([1,3,5,7,9])
j = np.array([0,2,4,6,8])
k = np.array([2,3,5,7])
chewy[i[:, None, None], j[None, :, None], k[None, None, :]] = 1
print(chewy)
## [[[0. 0. 0. 0. 0. 0. 0. 0. 0. 0.]
##   [0. 0. 0. 0. 0. 0. 0. 0. 0. 0.]
##   [0. 0. 0. 0. 0. 0. 0. 0. 0. 0.]
##   [0. 0. 0. 0. 0. 0. 0. 0. 0. 0.]
##   [0. 0. 0. 0. 0. 0. 0. 0. 0. 0.]
##   [0. 0. 0. 0. 0. 0. 0. 0. 0. 0.]
##   [0. 0. 0. 0. 0. 0. 0. 0. 0. 0.]
##   [0. 0. 0. 0. 0. 0. 0. 0. 0. 0.]
##   [0. 0. 0. 0. 0. 0. 0. 0. 0. 0.]
##   [0. 0. 0. 0. 0. 0. 0. 0. 0. 0.]]
## 
##  [[0. 0. 1. 1. 0. 1. 0. 1. 0. 0.]
##   [0. 0. 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0. 0. 0. 0. 0.]
##   [0. 0. 0. 0. 0. 0. 0. 0. 0. 0.]]
## 
##  [[0. 0. 1. 1. 0. 1. 0. 1. 0. 0.]
##   [0. 0. 0. 0. 0. 0. 0. 0. 0. 0.]
##   [0. 0. 1. 1. 0. 1. 0. 1. 0. 0.]
##   [0. 0. 0. 0. 0. 0. 0. 0. 0. 0.]
##   [0. 0. 1. 1. 0. 1. 0. 1. 0. 0.]
##   [0. 0. 0. 0. 0. 0. 0. 0. 0. 0.]
##   [0. 0. 1. 1. 0. 1. 0. 1. 0. 0.]
##   [0. 0. 0. 0. 0. 0. 0. 0. 0. 0.]
##   [0. 0. 1. 1. 0. 1. 0. 1. 0. 0.]
##   [0. 0. 0. 0. 0. 0. 0. 0. 0. 0.]]]

Course Curriculum

  1. Introduction
    1.1 Introduction
  2. Basic Array Stuff
    2.1 NumPy Array Motivation
    2.2 NumPy Array Basics
    2.3 Creating NumPy Arrays
    2.4 Indexing 1-D Arrays
    2.5 Indexing Multidimensional Arrays
    2.6 Basic Math On Arrays
    2.7 Challenge: High School Reunion
    2.8 Challenge: Gold Miner
    2.9 Challenge: Chic-fil-A
  3. Intermediate Array Stuff
    3.1 Broadcasting
    3.2 newaxis
    3.3 reshape()
    3.4 Boolean Indexing
    3.5 nan
    3.6 infinity
    3.7 random
    3.8 Challenge: Love Distance
    3.9 Challenge: Professor Prick
    3.10 Challenge: Psycho Parent
  4. Common Operations
    4.1 where()
    4.2 Math Functions
    4.3 all() and any()
    4.4 concatenate()
    4.5 Stacking
    4.6 Sorting
    4.7 unique()
    4.8 Challenge: Movie Ratings
    4.9 Challenge: Big Fish
    4.10 Challenge: Taco Truck
  5. Advanced Array Stuff
    5.1 Advanced Array Indexing
    5.2 View vs Copy
    5.3 Challenge: Population Verification
    5.4 Challenge: Prime Locations
    5.5 Challenge: The Game of Doors
    5.6 Challenge: Peanut Butter
  6. Final Boss
    6.1 as_strided()
    6.2 einsum()
    6.3 Challenge: One-Hot-Encoding
    6.4 Challenge: Cumulative Rainfall
    6.5 Challenge: Table Tennis
    6.6 Challenge: Where’s Waldo
    6.7 Challenge: Outer Product

Additional Content

  1. Python Pandas For Your Grandpa
  2. Neural Networks For Your Dog
  3. Introduction To Google Colab