diff --git a/Python/000_basics.py b/Python/000_basics.py index c11c446..edf6c99 100644 --- a/Python/000_basics.py +++ b/Python/000_basics.py @@ -24,4 +24,31 @@ print("Your age is:", age) age = age + 1 # Age is now equal to 33 # Someone had a birthday! -print("Happy Birthday! You are now", age, "years old!") \ No newline at end of file +print("Happy Birthday! You are now", age, "years old!") + +# Simple math operators can be combined for the sake of brevity. +# These are called "compound" operators +# age = age + 1 +# is the same as +# age += 1 +# +# Basic compound operators: += -= *= /= (/= is a floating point operator) +# (A special //= which returns integer) +unused_age = 100 +print(f"Unused Age: {unused_age}") +unused_age -= 1 # unused_age is now 99 +print(f"Unused Age: {unused_age}") +unused_age += 3 # unused_age is now 102 +print(f"Unused Age: {unused_age}") +unused_age *= 4 # unused_age is now 408 +print(f"Unused Age: {unused_age}") +unused_age //= 2 # unused_age is now 204 +print(f"Unused Age: {unused_age}") + +# There is a common operator used in programming called the "modulo" or "modulus". +# This operator is a division operator that returns the remainder after +# the division is complete. +unused_age %= 100 +print(f"Unused Age: {unused_age}") + +