Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
import numpy as np
a1=np.array([1,2,3])
a2=np.array([4,5,6])
print (a1+a2)
#Output:[5 7 9]
print (a1*3)
#Output:[3 6 9]
print (a1*a2)
#Output:[ 4 10 18]
b1=[1,2,3]
b2=[4,5,6]
#Concatenation
print (b1+b2)
#Output:[1, 2, 3, 4, 5, 6]
#Repetition
print (b1*3)
#Output:[1, 2, 3, 1, 2, 3, 1, 2, 3]
print (b1*b2)
#Output:TypeError: can't multiply sequence by non-int of type 'list'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment