python program to alias an array and understand how aliasing concept in arrays work
python program to alias an array
and understand how aliasing
concept in arrays work
=================================================
code
from numpy import *
a = arange(1,11)
b = a #giving another name b to a
print('Before Modification:')
print('Original Array:',a)
print('Alias Array:',b)
print('#####################')
b[0]=20
print('After Modification:')
print('Original Array:',a)
print('Alias Array:',b)
output
Before Modification:
Original Array: [ 1 2 3
4 5 6
7 8 9 10]
Alias Array: [ 1 2 3
4 5 6
7 8 9 10]
#####################
After Modification:
Original Array: [20 2 3
4 5 6
7 8 9 10]
Alias Array: [20 2 3
4 5 6
7 8 9 10]
No comments:
Post a Comment