0 votes
1 view
in Python by (47.8k points)

How can I represent an infinite number in python? No matter which number you enter in the program, no number should be greater than this representation of infinity.

2 Answers

0 votes
by (107k points)
edited by
 
Best answer

To represent an infinite number in Python, you can run the following code this is float infinity value which will be greater than any other value:

test = float("inf")

To check representation of an infinite number in Python 3.5, you can run the following piece of code:-

import math

test = math.inf

To know more about this you can have a look at the following video tutorial:-

0 votes
by (31.4k points)

Since the release of Python 3.5, we can use math.inf see the code below:-

import math 

math.inf inf

Welcome to Intellipaat Community. Get your technical queries answered by top developers !


Categories

...