In the sympy module, we can test whether a given number n is odd or not using sympy.is_odd() function.
Syntax: sympy.is_odd(n) Parameter: n; number to be tested Return: bool value result
Code #1:
Python3
# Python program to check odd number# using sympy.is_odd() method# importing sympy modulefrom sympy import *# calling is_odd function on different numbersgeek1 = simplify(30).is_oddgeek2 = simplify(13).is_oddprint(geek1)print(geek2) |
Output:
False True
Code #2:
Python3
# Python program to check odd number# using sympy.is_odd() method# importing sympy modulefrom sympy import *# calling is_odd function on different numbersgeek1 = simplify(2).is_oddgeek2 = simplify(2.5).is_oddprint(geek1)print(geek2) |
Output:
False False
