Maths
line-by-line explanation of your math operations in Python:
#!/bin/python3
Shebang line: tells the system to use the Python 3 interpreter.
#math
A comment indicating that the following lines perform math operations.
Math operations:
print(50 + 50) # Addition β 100
print(60 - 50) # Subtraction β 10
print(50 * 50) # Multiplication β 2500
print(50 + 50 - 50 * 50 / 50)
# Order of operations (PEMDAS):
# 50 * 50 = 2500
# 2500 / 50 = 50
# 50 + 50 - 50 = 50
# Final result β 50.0
print(50 ** 2) # Exponentiation β 50^2 = 2500
print(50 % 8) # Modulus (remainder) β 50 Γ· 8 = 6 R2 β Result: 2
print(50 / 8) # Division β Result: 6.25
print(50 // 8) # Floor division β Result: 6 (no decimals)
β Summary of operators used:
+
: Addition-
: Subtraction*
: Multiplication/
: Division**
: Exponentiation%
: Modulus (remainder)//
: Floor division (integer result)
#!/bin/python3
#math
print(50 + 50)
print(60 - 50)
print(50 * 50)
print(50 + 50 - 50 * 50 / 50)
print(50 ** 2)
print(50 % 8)
print(50 / 8)
print(50 // 8)

Last updated