Thursday, October 9, 2025
HomeLanguagesPython | Numpy np.polyone() method

Python | Numpy np.polyone() method

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]]

Dominic
Dominichttp://wardslaus.com
infosec,malicious & dos attacks generator, boot rom exploit philanthropist , wild hacker , game developer,
RELATED ARTICLES

Most Popular

Dominic
32346 POSTS0 COMMENTS
Milvus
87 POSTS0 COMMENTS
Nango Kala
6714 POSTS0 COMMENTS
Nicole Veronica
11877 POSTS0 COMMENTS
Nokonwaba Nkukhwana
11940 POSTS0 COMMENTS
Shaida Kate Naidoo
6835 POSTS0 COMMENTS
Ted Musemwa
7094 POSTS0 COMMENTS
Thapelo Manthata
6789 POSTS0 COMMENTS
Umr Jansen
6791 POSTS0 COMMENTS