Python Math.inf Code Example


Example 1: python math negative infinity


# Import math Library
import math

# Print the positive infinity
print (math.inf)

# Print the negative infinity
print (-math.inf)

Example 2: math pyhon ?


Arithmetic:
operator | name | example |
+ Addition x + y
- Subtraction x - y
* Multiplication x * y
/ Division x / y
% Modulus x % y
** Exponentiation x ** y
// Floor division x // y

Comparison:
Operator | Name | Example |
== Equal x == y
!= Not equal x != y
> Greater than x > y
< Less than x < y
>= Greater than or equal to x >= y
<= Less than or equal to x <= y

Assignment:
Operator | Example |
= x = 5
+= x += 3
-= x -= 3
*= x *= 3
/= x /= 3
%= x %= 3
//= x //= 3
**= x **= 3
&= x &= 3
|= x |= 3
^= x ^= 3
>>= x >>= 3
<<= x <<= 3

Example 3: python mathematics


// Python mathematical functions include but are not limited to:
print(10+10) // Returns 20 (Addition)
print(10*10) // Returns 100 (Multiplication)
print(10/10) // Returns 1 (Division)
print(10**10) // Returns 10000000000 (10 to the power of 10, 10^10)
print(10-10) // Returns 0 (Subtraction)
print(10>100) // Returns False (If A is greater than B)
print(10<100) // Returns True (If A is less than B)
print(10==10) // Returns True (If A is equal to B)

import math // Required for the function below
print(math.pi) // Returns the first 15 decimal places of Pi

Comments

Popular posts from this blog

Converting A String To Int In Groovy

"Cannot Create Cache Directory /home//.composer/cache/repo/https---packagist.org/, Or Directory Is Not Writable. Proceeding Without Cache"

Android How Can I Convert A String To A Editable