Mabaquiao Jezreel PythonExercise3
Mabaquiao Jezreel PythonExercise3
Objectives:
● Understand the programming fundamentals and the Python language.
● Write Python programs that utilize variables, data types, and operators.
Instructions:
1. To complete this exercise, please follow the sample commands in Python provided to you.
Once you have completed the assignment, please submit the IPython file and this
document to me. You have one week to complete the exercise from the assigned date.
Please let me know if you have any questions or concerns regarding the assignment.
2. When submitting your completed assignment, please name the IPython file as follows:
"surname_firstname_MP1Exercise". Replace "surname" with your last name, "firstname" with
your first name, and "MP2Exercise" with the name of the machine problem.
For example, if your name is John Smith and the machine problem is "PythonExercise2", the
file name should be "smith_john_PythonExercise1.ipynb".
Please adhere to this naming convention when submitting your file. This will ensure I can
quickly identify your submission and provide appropriate feedback.
Arithmetic: You can easily perform array with array arithmetic, or scalar with array
arithmetic.
In [5] # This will raise a Warning on division by zero, but not an error!
# It just fills the spot with nan
arr/arr
Out[5] array([nan, 1., 1., 1., 1., 1., 1., 1., 1., 1.])
In [7] arr**3
Out[7] array([ 0, 1, 8, 27, 64, 125, 216, 343, 512, 729], dtype=int32)
Universal Array Functions: NumPy comes with many universal array functions, or
ufuncs, which are essentially just mathematical operations that can be applied
across the array.
Summary Statistics on Arrays: NumPy also offers common statistics like sum, mean,
and max.
In [13] arr.sum()
Out[13] np.int32(45)
In [14] arr.mean()
Out[14] np.float64(4.5)
In [15] arr.max()
Out[15] np.int32(9)
In [17] arr_2d.sum(axis=0)
In [18] arr_2d.shape
Out[18] (3, 4)