How to Represent an Infinite Number in Python?

 

How to Represent an Infinite Number in Python?

To represent an infinite number you need to define a specific rule. For example, the infinite number in the examples of this article is represented as a string developed in the Python programming language. If you have any questions or suggestions kindly use the comment section and help us build a better article.

python infinite value

By Ugliest UnicornUgliest Unicorn on Mar 26, 2020
test = float("inf")

In Python 3.5, you can do:

import math
test = math.inf

Add Comment

5

infinity in python

By Aggressive AddaxAggressive Addax on Jan 31, 2021
# Defining a positive infinite integer 
positive_infnity = float('inf') 
print('Positive Infinity: ', positive_infnity) 
  
# Defining a negative infinite integer 
negative_infnity = float('-inf') 
print('Negative Infinity: ', negative_infnity)

Comments

Popular posts from this blog

How to Send Whatsapp Message Through HTML Link?

rigidbody.addforce not working

How to Change the Text Button Color in the Flutter?