Tuesday, June 16, 2026
HomeLanguagesPython | Numpy np.legone() method

Python | Numpy np.legone() method

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

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

Example #1 :




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


Output :

[1]

Example #2 :




# Python program explaining
# numpy.legone() method 
  
# import numpy and legone
import numpy as np
from numpy.polynomial.legendre import legone
  
# using np.legone() method
ans = legone + [[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
32516 POSTS0 COMMENTS
Milvus
131 POSTS0 COMMENTS
Nango Kala
6897 POSTS0 COMMENTS
Nicole Veronica
12013 POSTS0 COMMENTS
Nokonwaba Nkukhwana
12109 POSTS0 COMMENTS
Shaida Kate Naidoo
7019 POSTS0 COMMENTS
Ted Musemwa
7262 POSTS0 COMMENTS
Thapelo Manthata
6976 POSTS0 COMMENTS
Umr Jansen
6964 POSTS0 COMMENTS