Skip to content

Instantly share code, notes, and snippets.

@Robofied
Created February 15, 2019 18:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Robofied/c8651a57e59442dcd47655105cc52ef5 to your computer and use it in GitHub Desktop.
Save Robofied/c8651a57e59442dcd47655105cc52ef5 to your computer and use it in GitHub Desktop.
Numpy
## 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