# Python | sympy.count_ops() method

Using the `count_ops()` method in simpy module, we can count the number of operations used in the mathematical function. `count_ops()` method returns the number of operations used in the mathematical function.

```Syntax : sympy.count_ops()

Return : the count of operations.```

Code #1:

With the help of below examples, we can clearly understand that using` sympy.count_ops()` method we can count the number of operations in given expression.

 `# importing sympy library ` `from` `sympy ``import` `*` ` `  `# taking symbols ` `x, y, z ``=` `symbols(``'x y z'``) ` ` `  `# calling count_ops() method on expression ` `geek ``=` `sqrt((x ``+` `1``)``*``*``2` `+` `x).count_ops() ` `print``(geek) `

Output:

`5`

Code #2:

 `# importing sympy library ` `from` `sympy ``import` `*` ` `  `# taking symbols ` `a, b ``=` `symbols(``'a b'``) ` ` `  `# calling count_ops() method on expression ` `geek ``=` `log(a) ``+` `log(b) ``+` `log(a)``*``log(``1` `/` `b) ` `print``(count_ops(geek)) `

Output:

`8`

Code #3:

 `# importing sympy library ` `from` `sympy ``import` `*` ` `  `# taking symbols ` `a, b ``=` `symbols(``'a b'``) ` ` `  `# calling count_ops() method on expression ` `geek ``=` `log(a ``*` `b``*``*``(``1` `-` `log(a))) ` `print``(count_ops(geek)) `

Output:

`5`

My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.

Article Tags :

Be the First to upvote.

Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.