January 2019
Beginner
318 pages
8h 23m
English
Universal functions perform the operations on all the elements in a numpy array. Now, we are going to look at an example to perform multiple universal functions on an array. First, we are going to take the square root of the array. Create a script called sqrt_array.py and write the following content in it:
import numpy as nparray = np.arange(16)print("The Array is : ",array)Square_root = np.sqrt(array)print("Square root of given array is : ", Square_root)
Run the script and you will get the following output:
student@ubuntu:~/work$ python3 sqrt_array.py
The output is as follows:
The Array is : [ 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15]Square root of given array is : [0. 1. 1.41421356 1.73205081 2. 2.23606798 2.44948974 ...
Read now
Unlock full access