import numpy as np

"""
Explanation: <a href='http://www.pieriandata.com'> <img src='../Pierian_Data_Logo.png' /></a>

<center>Copyright Pierian Data 2017</center>
<center>For more information, visit us at www.pieriandata.com</center>
NumPy Exercises
Now that we've learned about NumPy let's test your knowledge. We'll start off with a few simple tasks and then you'll be asked some more complicated questions.
 IMPORTANT NOTE! Make sure you don't run the cells directly above the example output shown, otherwise you will end up writing over the example output! 
Import NumPy as np
End of explanation
"""


# CODE HERE
np.zeros(10)

"""
Explanation: Create an array of 10 zeros
End of explanation
"""


# CODE HERE
np.ones(10)

"""
Explanation: Create an array of 10 ones
End of explanation
"""


# CODE HERE
np.ones(10) * 5

"""
Explanation: Create an array of 10 fives
End of explanation
"""


# CODE HERE
np.arange(10, 51)

"""
Explanation: Create an array of the integers from 10 to 50
End of explanation
"""


# CODE HERE
np.arange(10, 51, 2)

"""
Explanation: Create an array of all the even integers from 10 to 50
End of explanation
"""


# CODE HERE
np.arange(9).reshape(3,3)

"""
Explanation: Create a 3x3 matrix with values ranging from 0 to 8
End of explanation
"""


# CODE HERE
np.eye(3)

"""
Explanation: Create a 3x3 identity matrix
End of explanation
"""


# CODE HERE
np.random.randn(1)

"""
Explanation: Use NumPy to generate a random number between 0 and 1
End of explanation
"""


# CODE HERE
np.random.randn(25)

"""
Explanation: Use NumPy to generate an array of 25 random numbers sampled from a standard normal distribution
End of explanation
"""


np.arange(1, 101).reshape(10, 10) / 100

"""
Explanation: Create the following matrix:
End of explanation
"""


np.linspace(0, 1, 20)

"""
Explanation: Create an array of 20 linearly spaced points between 0 and 1:
End of explanation
"""


# HERE IS THE GIVEN MATRIX CALLED MAT
# USE IT FOR THE FOLLOWING TASKS
mat = np.arange(1,26).reshape(5,5)
mat

# WRITE CODE HERE THAT REPRODUCES THE OUTPUT OF THE CELL BELOW
# BE CAREFUL NOT TO RUN THE CELL BELOW, OTHERWISE YOU WON'T
# BE ABLE TO SEE THE OUTPUT ANY MORE

mat[2:, ]

# WRITE CODE HERE THAT REPRODUCES THE OUTPUT OF THE CELL BELOW
# BE CAREFUL NOT TO RUN THE CELL BELOW, OTHERWISE YOU WON'T
# BE ABLE TO SEE THE OUTPUT ANY MORE

mat[3, -1]

# WRITE CODE HERE THAT REPRODUCES THE OUTPUT OF THE CELL BELOW
# BE CAREFUL NOT TO RUN THE CELL BELOW, OTHERWISE YOU WON'T
# BE ABLE TO SEE THE OUTPUT ANY MORE

mat[:3, 1].reshape(3, 1)

# WRITE CODE HERE THAT REPRODUCES THE OUTPUT OF THE CELL BELOW
# BE CAREFUL NOT TO RUN THE CELL BELOW, OTHERWISE YOU WON'T
# BE ABLE TO SEE THE OUTPUT ANY MORE

mat[-1, :]

# WRITE CODE HERE THAT REPRODUCES THE OUTPUT OF THE CELL BELOW
# BE CAREFUL NOT TO RUN THE CELL BELOW, OTHERWISE YOU WON'T
# BE ABLE TO SEE THE OUTPUT ANY MORE

mat[-2:, :]

"""
Explanation: Numpy Indexing and Selection
Now you will be given a few matrices, and be asked to replicate the resulting matrix outputs:
End of explanation
"""


# CODE HERE
np.sum(mat)

"""
Explanation: Now do the following
Get the sum of all the values in mat
End of explanation
"""


# CODE HERE
np.std(mat)

"""
Explanation: Get the standard deviation of the values in mat
End of explanation
"""


# CODE HERE
np.sum(mat, axis = 0)

"""
Explanation: Get the sum of all the columns in mat
End of explanation
"""


# My favourite number is 7
np.random.seed(7)

"""
Explanation: Bonus Question
We worked a lot with random data with numpy, but is there a way we can insure that we always get the same random numbers? Click Here for a Hint
End of explanation
"""


