Import NumPy as Npdef main (): lst=[[1,3,5],[2,4,6] Print (' Hello World ') print (type (LST)) Np_lst = Np.array (ls T) print (type (np_lst)) Np_lst = Np.array (lst,dtype=np.float) print (Type (NP_LST)) print (Np_lst.shape) print ( Np_lst.ndim) print (np_lst.dtype) print (np_lst.itemsize) print (np_lst.size) #2 Some Arrays Print (Np.zeros ([2 , 4]) #两行四列 print (Np.ones ([3,5])) print ("Rand:") print (Np.random.rand (2,4)) print (Np.random.rand ()) Print (" Randint: ") Print (Np.random.randint (1,10,3)) print (" RANDN: ") print (NP.RANDOM.RANDN (2,4)) print (" Choice: ") pr Int (Np.random.choice ([10,20,30,40])) print ("Distribute:") print (Np.random.beta (1,20,100)) #3 numpy opes LST=NP . Arange (1,11). Reshape ([2,-1]) print ("Exp:") print (Np.exp (LST)) print ("EXP2:") Print (NP.EXP2 (LST)) print ("sq RT: ") Print (NP.SQRT (LST)) print (" Sin: ") print (Np.sin (LST)) print (" log: ") print (Np.log (LST)) if __name__ = = ' __main__ ': Main ()
Python Learning NumPy Combat