From a579b51489651702990dc670f0999b18fc25e54b Mon Sep 17 00:00:00 2001 From: Saketh Karumuri Date: Thu, 4 Aug 2022 19:55:44 -0700 Subject: [PATCH 1/2] Added the base code for the calculator --- calculator.py | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 calculator.py diff --git a/calculator.py b/calculator.py new file mode 100644 index 0000000..93e7288 --- /dev/null +++ b/calculator.py @@ -0,0 +1,35 @@ +from argparse import ArgumentError +import sys + +def add(x, y): + pass + +def sub(x, y): + pass + +def mult(x, y): + pass + +def div(x, y): + pass + +if __name__ == '__main__': + if len(sys.argv) != 3: + raise ArgumentError("Incorrect Number of Arguments") + + x = sys.argv[1] + y = sys.argv[2] + + if sys.argv[0].lower() == "add": + print(add(x, y)) + + elif sys.argv[0].lower() == "sub": + print(sub(x, y)) + + elif sys.argv[0].lower() == "mult": + print(mult(x, y)) + + elif sys.argv[0].lower() == "div": + print(div(x, y)) + + else: raise ArgumentError("Invalid Operation") \ No newline at end of file From e0efa4a174211dc8b4748596ee201b5e61c3e807 Mon Sep 17 00:00:00 2001 From: Ileen Fan Date: Sat, 6 Aug 2022 22:57:37 -0700 Subject: [PATCH 2/2] add subtraction functionality --- .idea/.gitignore | 3 +++ .idea/GUI.iml | 8 ++++++++ .idea/inspectionProfiles/profiles_settings.xml | 6 ++++++ .idea/misc.xml | 4 ++++ .idea/modules.xml | 8 ++++++++ .idea/vcs.xml | 6 ++++++ calculator.py | 2 +- 7 files changed, 36 insertions(+), 1 deletion(-) create mode 100644 .idea/.gitignore create mode 100644 .idea/GUI.iml create mode 100644 .idea/inspectionProfiles/profiles_settings.xml create mode 100644 .idea/misc.xml create mode 100644 .idea/modules.xml create mode 100644 .idea/vcs.xml diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..26d3352 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,3 @@ +# Default ignored files +/shelf/ +/workspace.xml diff --git a/.idea/GUI.iml b/.idea/GUI.iml new file mode 100644 index 0000000..d0876a7 --- /dev/null +++ b/.idea/GUI.iml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/inspectionProfiles/profiles_settings.xml b/.idea/inspectionProfiles/profiles_settings.xml new file mode 100644 index 0000000..105ce2d --- /dev/null +++ b/.idea/inspectionProfiles/profiles_settings.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..7e83473 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..4c064bc --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..94a25f7 --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/calculator.py b/calculator.py index 93e7288..4a43019 100644 --- a/calculator.py +++ b/calculator.py @@ -5,7 +5,7 @@ def add(x, y): pass def sub(x, y): - pass + return x-y def mult(x, y): pass