Math Antics python code example

Example 1: 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 2: python math operators

# Below follow the math operators that can be used in python
# ** Exponent	
2 ** 3 # Output: 8
# % Modulus/Remaider	
22 % 8 # Output: 6
# // Integer division	
22 // 8 # Output: 2
# / Division	
22 / 8 # Output: 2.75
# * Multiplication	
3 * 3 # Output: 9
# - Subtraction	
5 - 2 # Output: 3
# + Addition	
2 + 2 # Output: 4

Tags:

Css Example