En el módulo simpy, podemos probar si un número dado n es negativo o no usando la función sympy.is_negative().
Syntax: sympy.is_negative(n) Parameter: n; number to be tested Return: bool value result
Código #1:
Python3
# Python program to check negative number # using sympy.is_negative() method # importing sympy module from sympy import * # calling is_negative function on different numbers geek1 = simplify(-21).is_negative geek2 = simplify(0).is_negative print(geek1) print(geek2)
Producción:
True False
Código #2:
Python3
# Python program to check negative number # using sympy.is_negative() method # importing sympy module from sympy import * # calling is_negative function on different numbers geek = simplify(-002).is_negative print(geek)
Producción:
True