Python| sympy.is_odd() 方法
在 simpy 模块中,我们可以使用sympy.is_odd()
函数测试给定数字 n 是否为奇数。
Syntax: sympy.is_odd(n)
Parameter: n; number to be tested
Return: bool value result
代码#1:
# Python program to check odd number
# using sympy.is_odd() method
# importing sympy module
from sympy import *
# calling is_odd function on different numbers
geek1 = simplify(30).is_odd
geek2 = simplify(13).is_odd
print(geek1)
print(geek2)
输出:
False
True
代码#2:
# Python program to check odd number
# using sympy.is_odd() method
# importing sympy module
from sympy import *
# calling is_odd function on different numbers
geek = simplify(2).is_odd
print(geek)
输出:
False
在评论中写代码?请使用 ide.geeksforgeeks.org,生成链接并在此处分享链接。