Create simple_math.py
This commit is contained in:
30
python/simple_math.py
Normal file
30
python/simple_math.py
Normal file
@@ -0,0 +1,30 @@
|
||||
a = 9
|
||||
b = 7
|
||||
|
||||
# ADD 2 NUMBERS
|
||||
print(a + b)
|
||||
|
||||
# MULTIPLY 2 NUMBERS
|
||||
c = a * b
|
||||
print(c)
|
||||
|
||||
# DIVIDE 2 NUMBERS
|
||||
d = a / b
|
||||
print (d)
|
||||
|
||||
# INTEGER DIVISION
|
||||
e = a // b
|
||||
print(e)
|
||||
|
||||
# EXPONENT: b squared
|
||||
print(b ** 2)
|
||||
|
||||
# MODULUS - remainder of a division
|
||||
print(b % 3)
|
||||
print(a % 4)
|
||||
|
||||
# EVEN? OR ODD - USE MOD
|
||||
print(a % 2 == 0)
|
||||
print(14 % 2 == 0)
|
||||
# single = sign is for assigning a value to a variable
|
||||
# double == is for comparisons
|
||||
Reference in New Issue
Block a user