Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add #4

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions calculator.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
from argparse import ArgumentError
import sys

def add(x, y):
return x+y

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")