Skip to content
Related Articles

Related Articles

Improve Article

Python | Numpy np.legone() method

  • Last Updated : 31 Dec, 2019

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

 Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.  

To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course. And to begin with your Machine Learning Journey, join the Machine Learning – Basic Level Course

My Personal Notes arrow_drop_up
Recommended Articles
Page :