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

Update calc.py #1

Open
wants to merge 1 commit into
base: master
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
48 changes: 24 additions & 24 deletions calc.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,28 +14,28 @@
# -------------------------------------------------------- #

# Add function
# a -- addend
# b -- augend
def add(a, b):
return a + b
# num1 -- addend
# num2 -- augend
def add(num1, num2):
return num1 + num2

# Subtract function
# a -- minuend
# b -- subtrahend
def sub(a, b):
return a - b
def sub(num1, num2):
return num1 - num2

# Multiply function
# a -- multiplicand
# b -- multiplier
def mult(a, b):
return a * b
# num1 -- multiplicand
# num2 -- multiplier
def mult(num1, num2):
return num1 * num2

# Divide function
# a -- dividend
# b -- divisor
def div(a, b):
return a / b
# num1 -- dividend
# num2 -- divisor
def div(num1, num2):
return num1 / num2


# -------------------------------------------------------- #
Expand All @@ -45,32 +45,32 @@ def div(a, b):
# -- MAIN FUNCTIONAILTY -- DO NOT EDIT ------------------- #
# -------------------------------------------------------- #

a = None
b = None
num1 = None
num2 = None
op = None

while (True):
# get input values
a = raw_input("Enter the first argument: ")
num1 = raw_input("Enter the first argument: ")
op = raw_input("Enter the operation: ")
b = raw_input("Enter the second argument: ")
num1 = raw_input("Enter the second argument: ")
try:
a = int(a)
b = int(b)
num1 = int(num1)
num2 = int(num2)
except ValueError:
print "Invalid number argument..."
op = None

# decide function
if (op != None):
if (op == "+"):
print "Sum: ", add(a, b)
print "Sum: ", add(num1, num2)
elif (op == "-"):
print "Difference: ", sub(a, b)
print "Difference: ", sub(num1, num2)
elif (op == "*"):
print "Product: ", mult(a, b)
print "Product: ", mult(num1, num2)
elif (op == "/"):
print "Quotient: ", div(a, b)
print "Quotient: ", div(num1, num2)
else:
print "Invalid operation..."

Expand Down