Created
February 15, 2019 18:29
-
-
Save Robofied/c8651a57e59442dcd47655105cc52ef5 to your computer and use it in GitHub Desktop.
Numpy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## Importing numpy library for creating numpy | |
import numpy as np | |
## Creating a 1-D array | |
a = np.array([0,2,1]) | |
print(a) | |
#[Output]: | |
#array([0, 2, 1]) | |
## assigning array "a" to array "b" | |
## This is simple assignment neither view nor copy | |
b = a | |
## Checking the value in b | |
print(b) | |
#[Output]: | |
#[0 2 1] | |
## Checking the id's of b and a | |
## Both are having same id'd in simple assignment. | |
print(id(b)) | |
print(id(a)) | |
#[Output]: | |
#2090539997104 | |
#2090539997104 | |
##See changes if value in any array is updated | |
##Changing the values in b | |
b[0] = 3 | |
print(b) | |
#[Output]: | |
#[3 2 1] | |
## Checking if changes is also reflected in a or not. | |
print(a) | |
#[Output]: | |
#[3 2 1] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment