From 4d14c89efbcc6f63fe5cf6cbae1bdadf2f32423e Mon Sep 17 00:00:00 2001 From: Jordan1-34 <131589592+Jordan1-34@users.noreply.github.com> Date: Sat, 3 Aug 2024 11:36:23 +0100 Subject: [PATCH] 016_operators.py --- 016_operators.py | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/016_operators.py b/016_operators.py index 64f8eb6d..88c1d6b1 100644 --- a/016_operators.py +++ b/016_operators.py @@ -54,13 +54,13 @@ def add_one(num): # == Subtraction == -# subtracted = 2 ? 3 -# print(f"2 ? 3 = {subtracted} (should be -1)") +subtracted = 2 - 3 +print(f"2 - 3 = {subtracted} (should be -1)") # == Division == -# divided = 2 ? 3 -# print(f"2 ? 3 = {divided} (should be 0.6666666666666666)") +divided = 2 / 3 +print(f"2 3 = {divided} (should be 0.6666666666666666)") # This kind of 'decimal point' number, 0.6666666666666666 is # called a float, by the way, meaning 'floating point'. @@ -68,28 +68,30 @@ def add_one(num): # == Modulus == # Sometimes known as "remainder if we divide 3 by 2" -# modulus = 3 ? 2 -# print(f"3 ? 2 = {modulus} (should be 1)") +modulus = 3 / 2 +print(f"3 / 2 = {modulus} (should be 1)") # == Floor division == # Sometimes known as "division without remainder" -# floor_divided = 2 ? 3 -# print(f"2 ? 3 = {floor_divided} (should be 0)") +floor_divided = 2 / 3 +print(f"2 / 3 = {floor_divided} (should be 0)") # == Exponentiation == # Sometimes known as "2 to the power of 3" -# expr = 2 ? 3 -# print(f"2 ? 3 = {expr} (should be 8)") +expr = 2 ** 3 +print(f"2 ** 3 = {expr} (should be 8)") # There are many more operators in Python that you can # research. You're very welcome to try out a few below: # OPERATOR PLAYGROUND STARTS +expr = 6 / 3 +print(f"6 / 3 = {expr} (should be 2)") - - +expr = 6 // 3 +print(f"6 // 3 = {expr} (should be 2)") # OPERATOR PLAYGROUND ENDS # Happy? Move on to 017_expressions.py