Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Infinity in Python

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 5.92k
    Comment on it

    There can be positive infinity and negative infinity in python represented by Inf and -Inf. Positive infinity which is greatest of all numbers and negative infinity is least of all numbers.

    Program to demonstrate infinity:

    # Positive Infinity
    p_infinity = float('Inf')
     
    if 99999999999999 > p_infinity:
        print("The number is greater than Infinity!")
    else:
        print("Infinity is greatest")
     
    # Negative Infinity
    n_infinity = float('-Inf')
    if -99999999999999 < n_infinity:
        print("The number is lesser than Negative Infinity!")
    else:
        print("Negative Infinity is least")

    Output:

    Infinity is greatest
    Negative Infinity is least

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: