From 7c8fc8c3ec2db151934c5de2b73a5accd3f3b028 Mon Sep 17 00:00:00 2001 From: Max Roberts Date: Mon, 30 Jan 2023 23:33:49 +0000 Subject: [PATCH 1/2] Added multiplication --- scicalc | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/scicalc b/scicalc index a739b62..c81fb8f 100755 --- a/scicalc +++ b/scicalc @@ -35,6 +35,14 @@ def add(*args): sum += arg return sum +def mul(*args): + """multiplies a list of numbers""" + + product = 1.0 + for arg in args: + product = product * arg + return product + def log10(x): """Return a base-10 logarithm of x""" @@ -48,6 +56,7 @@ def log10(x): operators = { 'add': add, 'sum': add, + 'mul': mul, 'log10': log10, } From 7ee217bcdfedf417a943863dc3f1c2511e1a4ddc Mon Sep 17 00:00:00 2001 From: Max Roberts Date: Thu, 2 Feb 2023 05:21:32 +0000 Subject: [PATCH 2/2] Implemented subtraction --- scicalc | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/scicalc b/scicalc index 1667b1d..a360272 100755 --- a/scicalc +++ b/scicalc @@ -35,6 +35,13 @@ def add(*args): sum += arg return sum +def sub(*args): + """Subtracts any following numbers from the first number passed""" + result = args[0] + for n in args[1:]: + result -= n + return result + def mul(*args): """Multiply a list of numbers""" @@ -55,6 +62,7 @@ def log10(x): # operators = { 'add': add, + 'sub': sub, 'sum': add, 'mul': mul, 'log10': log10,