Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Python by (47.6k 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.

closed

2 Answers

0 votes
by (106k 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 (32.3k points)

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

import math 

math.inf inf

Related questions

31k questions

32.8k answers

501 comments

693 users

Browse Categories

...