Python | método sympy.is_nonnegative()

En el módulo simpy, podemos probar si un número dado n no es negativo o no usando la función sympy.is_nonnegative().
 

Syntax:  sympy.is_nonnegative(n)
Parameter:  n; number to be tested
Return:  bool value result 

Código #1: 
 

Python3

# Python program to check nonnegative number
# using sympy.is_nonnegative() method
 
# importing sympy module
from sympy import *
 
# calling is_nonnegative function on different numbers
geek1 = simplify(-21).is_nonnegative
geek2 = simplify(0).is_nonnegative
 
print(geek1)
print(geek2)

Producción: 
 

False
True

Código #2: 
 

Python3

# Python program to check nonnegative number
# using sympy.is_nonnegative() method
 
# importing sympy module
from sympy import *
 
# calling is_negative function on different numbers
geek = simplify(-002).is_nonnegative
 
print(geek)

Producción: 
 

False

Publicación traducida automáticamente

Artículo escrito por Shivam_k y traducido por Barcelona Geeks. The original can be accessed here. Licence: CCBY-SA

Deja una respuesta

Tu dirección de correo electrónico no será publicada. Los campos obligatorios están marcados con *