Open In App

Python | sympy.Mod() method

With the help of sympy.Mod() method, we can find the modulus and can give the parameters separately by using sympy.Mod() method.

Syntax : sympy.Mod(var1, var2)
Return : Return a value of modulo.



Example #1 :
In this example we can see that by using sympy.Mod() method, we are able to find the modulus for a given parameters.




# import sympy
from sympy import * 
  
x, y = symbols('x y')
  
# Using sympy.Mod() method
gfg = Mod(x, y).subs({x:7, y:2})
  
print(gfg)

Output :

1



Example #2 :




# import sympy
from sympy import * 
  
x, y = symbols('x y')
  
# Using sympy.Mod() method
gfg = Mod(x**2, y).subs({x:7, y:5})
  
print(gfg)

Output :

4

Article Tags :