Skip to content
Related Articles
Get the best out of our app
GeeksforGeeks App
Open App
geeksforgeeks
Browser
Continue

Related Articles

Python | sympy.ones() method

Improve Article
Save Article
Like Article
Improve Article
Save Article
Like Article

With the help of sympy.ones() method, we can create a matrix having dimension nxm and filled with ones by using sympy.ones() method.

Syntax : sympy.ones()
Return : Return a ones matrix.

Example #1 :
In this example, we can see that by using sympy.ones() method, we are able to create the ones matrix having dimension nxn all filled with ones, where nxm will be pass as a parameter.




# import sympy
from sympy import *
  
# Use sympy.ones() method
mat = ones(3, 4)
   
print(mat)

Output :

Matrix([
[1, 1, 1, 1],
[1, 1, 1, 1],
[1, 1, 1, 1]])

Example #2 :




# import sympy
from sympy import *
  
# Use sympy.ones() method
mat = ones(3, 2)
   
print(mat)

Output :

Matrix([
[1, 1],
[1, 1],
[1, 1]])

My Personal Notes arrow_drop_up
Last Updated : 29 Jun, 2019
Like Article
Save Article
Similar Reads
Related Tutorials