Python 3 Script to Check Whether Number is Infinite or Not Using Math and Numpy Module Full Example Project For Beginners

You are currently viewing Python 3 Script to Check Whether Number is Infinite or Not Using Math and Numpy Module Full Example Project For Beginners

 

 

Welcome folks today in this blog post we will be checking whether the number is infinite or not in python using math and numpy module. All the full source code of the application is shown below.

 

 

 

 

Get Started

 

 

 

In order to get started you need to make an app.py file and copy paste the following code

 

 

app.py

 

 

import numpy as np
import math

# Defining a positive infinite integer
a = np.inf

# Defining a negative infinite integer
b = -np.inf

# Define a finite integer
c = 300

# chech if a in infinite
print(math.isinf(a))

# chech if b in infinite
print(math.isinf(b))

# chech if c in infinite
print(math.isinf(c))

 

 

Now if you execute the python script by typing the below command as shown below

 

 

python app.py

 

 

 

Leave a Reply