Integer class
The integer class in sympy is used to represent the integers. It converts floating-point numbers and rational numbers to integers. Syntax of Integer class is given below –
from sympy import Integer Integer(any_Number)
Here any_Number may be an Integer, rational number, and floating-point number.
Python3
from sympy import Integer # converting float to integer print (Integer( 1.5 )) # converting rational to integer print (Integer( 500 / 200 )) |
Output
1 2
Let’s look into an example code that describes some predefined singleton objects that represent a few important notations.
Python3
from sympy import S # represents not a number print (S.NaN) # represents Infinity print (S.Infinity) # represents imaginary value print (S.ImaginaryUnit) # represents 1/2 value print (S.Half) |
Output
nan oo I 1/2
What is the number class in SymPy?
Number class is represented atomic numbers in SymPy Python. It has three subclasses. They are Float, Rational, and Integer. These subclasses are used to represent different kinds of numbers like integers, floating decimals, and rational numbers. There are also some predefined singleton objects that represent NaN, Infinity, and imaginary numbers.