Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 25 additions & 21 deletions 06 Lesson Numpy/Numpy Test.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,15 @@
"id": "UelVcRZ-sAlh"
},
"outputs": [],
"source": []
"source": [import numpy as np]
},
{
"cell_type": "markdown",
"metadata": {
"colab_type": "text",
"id": "bu2Riq11sAlm"
},
"source": [
"source": [np.zeros(10)
"#### Create an array of 10 zeros "
]
},
Expand Down Expand Up @@ -77,7 +77,7 @@
"colab_type": "text",
"id": "qOm0No5tsAlt"
},
"source": [
"source": [np.ones(10)
"#### Create an array of 10 ones"
]
},
Expand Down Expand Up @@ -110,7 +110,7 @@
"colab_type": "text",
"id": "PmtViTmxsAly"
},
"source": [
"source": [ np.ones(10)*5
"#### Create an array of 10 fives"
]
},
Expand All @@ -132,7 +132,7 @@
"colab_type": "text",
"id": "o3GE-RG2sAl2"
},
"source": [
"source": [np.arange(10,51)
"#### Create an array of the integers from 10 to 50"
]
},
Expand Down Expand Up @@ -167,7 +167,7 @@
"colab_type": "text",
"id": "8W693KT0sAmA"
},
"source": [
"source": [np.arange(10,51,2)
"#### Create an array of all the even integers from 10 to 50"
]
},
Expand Down Expand Up @@ -201,7 +201,8 @@
"colab_type": "text",
"id": "O1WwNPlXsAmN"
},
"source": [
"source": [a = np.array([[0,1,2],[3,4,5],[6,7,8]])
np.transpose (a)
"#### Create a 3x3 matrix with values ranging from 0 to 8"
]
},
Expand Down Expand Up @@ -236,7 +237,8 @@
"colab_type": "text",
"id": "p3ch73fusAma"
},
"source": [
"source": [x = np.eye(3)
print(x)
"#### Create a 3x3 identity matrix"
]
},
Expand Down Expand Up @@ -271,7 +273,7 @@
"colab_type": "text",
"id": "TwNdLZ8LsAml"
},
"source": [
"source": [np.random.rand(1)
"#### Use NumPy to generate a random number between 0 and 1"
]
},
Expand Down Expand Up @@ -304,7 +306,7 @@
"colab_type": "text",
"id": "mqAJJt1FsAmr"
},
"source": [
"source": [np.random.randn(25)
"#### Use NumPy to generate an array of 25 random numbers sampled from a standard normal distribution"
]
},
Expand Down Expand Up @@ -341,7 +343,8 @@
"colab_type": "text",
"id": "L1iG-GdnsAmw"
},
"source": [
"source": [X_test = np.linespace(0,1,100)
X_test
"#### Create the following matrix:"
]
},
Expand Down Expand Up @@ -393,7 +396,7 @@
"colab_type": "text",
"id": "KBZEt6tlsAm2"
},
"source": [
"source": [np.linspace(0,1,20)
"#### Create an array of 20 linearly spaced points between 0 and 1:"
]
},
Expand Down Expand Up @@ -429,7 +432,8 @@
"colab_type": "text",
"id": "AC2rcInYsAnB"
},
"source": [
"source": [mat = np.arange(1,26).reashape(5,5)
mat
"## Numpy Indexing and Selection\n",
"\n",
"Now you will be given a few matrices, and be asked to replicate the resulting matrix outputs:"
Expand Down Expand Up @@ -471,7 +475,7 @@
"id": "_6ok-tAysAnG"
},
"outputs": [],
"source": [
"source": [ mat[2:,1:]
"# WRITE CODE HERE THAT REPRODUCES THE OUTPUT OF THE CELL BELOW\n",
"# BE CAREFUL NOT TO RUN THE CELL BELOW, OTHERWISE YOU WON'T\n",
"# BE ABLE TO SEE THE OUTPUT ANY MORE"
Expand Down Expand Up @@ -506,7 +510,7 @@
"id": "B4Mtdoj6sAnR"
},
"outputs": [],
"source": [
"source": [
"# WRITE CODE HERE THAT REPRODUCES THE OUTPUT OF THE CELL BELOW AS AN ARRAY\n",
"# BE CAREFUL NOT TO RUN THE CELL BELOW, OTHERWISE YOU WON'T\n",
"# BE ABLE TO SEE THE OUTPUT ANY MORE"
Expand All @@ -528,7 +532,7 @@
"output_type": "execute_result"
}
],
"source": []
"source": [mat [3][4]]
},
{
"cell_type": "code",
Expand All @@ -539,7 +543,7 @@
"id": "h8AJ_bd-sAna"
},
"outputs": [],
"source": [
"source": [ mat [0:3,1].reshape(3,1)
"# WRITE CODE HERE THAT REPRODUCES THE OUTPUT OF THE CELL BELOW\n",
"# BE CAREFUL NOT TO RUN THE CELL BELOW, OTHERWISE YOU WON'T\n",
"# BE ABLE TO SEE THE OUTPUT ANY MORE"
Expand Down Expand Up @@ -581,7 +585,7 @@
"id": "ngFWEzPPsAnp"
},
"outputs": [],
"source": [
"source": [ mat [4]
"# WRITE CODE HERE THAT REPRODUCES THE OUTPUT OF THE CELL BELOW\n",
"# BE CAREFUL NOT TO RUN THE CELL BELOW, OTHERWISE YOU WON'T\n",
"# BE ABLE TO SEE THE OUTPUT ANY MORE"
Expand Down Expand Up @@ -621,7 +625,7 @@
"id": "y0JlER1WsAnx"
},
"outputs": [],
"source": [
"source": [mat [3]
"# WRITE CODE HERE THAT REPRODUCES THE OUTPUT OF THE CELL BELOW\n",
"# BE CAREFUL NOT TO RUN THE CELL BELOW, OTHERWISE YOU WON'T\n",
"# BE ABLE TO SEE THE OUTPUT ANY MORE"
Expand Down Expand Up @@ -669,7 +673,7 @@
"colab_type": "text",
"id": "jBIAJoezsAn3"
},
"source": [
"source": [np.sum(mat)
"#### Get the sum of all the values in mat"
]
},
Expand Down Expand Up @@ -734,7 +738,7 @@
"colab_type": "text",
"id": "UKEr75mxsAn_"
},
"source": [
"source": [mat.sum(axis=0)
"#### Get the sum of all the columns in mat"
]
},
Expand Down