Open In App

Python | Numpy np.polyone() method

Improve
Improve
Like Article
Like
Save
Share
Report

np.polyone() method can be used instead of np.ones for creating a array whose elements are 1.

Syntax : np.polyone()
Return : Return array([1])

Example #1 :




    
# Python program explaining
# numpy.polyone() method 
  
# import numpy and polyone
import numpy as np
from numpy.polynomial.polynomial import polyone
  
# using np.polyone() method
ans = polyone
  
print(ans)


Output :

[1]

Example #2 :




# Python program explaining
# numpy.polyone() method 
  
# import numpy and polyone
import numpy as np
from numpy.polynomial.polynomial import polyone
  
# using np.polyone() method
ans = polyone + [[1, 3, 5], [2, 4, 6]]
  
print(ans)


Output :

[[2 4 6]
[3 5 7]]


Last Updated : 31 Dec, 2019
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads