在simpy模塊中,我們可以測試給定數字n是否為負數sympy.is_nonnegative()
函數。
用法: sympy.is_nonnegative(n) 參數: n; number to be tested 返回: bool value result
代碼1:
# Python program to check nonnegative number
# using sympy.is_nonnegative() method
# importing sympy module
from sympy import *
# calling is_nonnegative function on differnet numbers
geek1 = simplify(-21).is_nonnegative
geek2 = simplify(0).is_nonnegative
print(geek1)
print(geek2)
輸出:
False True
代碼2:
# Python program to check nonnegative number
# using sympy.is_nonnegative() method
# importing sympy module
from sympy import *
# calling is_negative function on differnet numbers
geek = simplify(-002).is_nonnegative
print(geek)
輸出:
False
相關用法
- Python os.dup()用法及代碼示例
- Python set()用法及代碼示例
- Python next()用法及代碼示例
- Python os.get_blocking()用法及代碼示例
- Python sympy.apart()用法及代碼示例
- Python sympy.nC()用法及代碼示例
- Python os.set_blocking()用法及代碼示例
- Python os.getcwd()用法及代碼示例
- Python os.access()用法及代碼示例
- Python dict pop()用法及代碼示例
- Python sympy.Add()用法及代碼示例
- Python sympy.nP()用法及代碼示例
注:本文由純淨天空篩選整理自Shivam_k大神的英文原創作品 Python | sympy.is_nonnegative() method。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。