Skip to content
Open
Show file tree
Hide file tree
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
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Better-Simple-Python-Calculator
A more functional simple calculator created in Python
40 changes: 26 additions & 14 deletions app.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,27 @@
def calc():
''' This is a functiion which when called, perform calculation tasks which user wants '''

num1 = float(input("Enter first number: "))
op = input("Enter operator: ")
num2 = float(input("Enter second number: "))

if op == "+" :
print(num1 + num2)
elif op == "-" :
print(num1 - num2)
elif op == "/" :
print(num1 / num2)
elif op == "*" :
print(num1 * num2)
elif op == "**" :
print(num1 ** num2)
else:
print("Invalid operator")

while True:
i = int(input("Press 1 to Continue, otherwise press 0\n"))
if i == 1:
calc()
else:
break

num1 = float(input("Enter first number: "))
op = input("Enter operator: ")
num2 = float(input("Enter second number: "))

if op == "+":
print(num1 + num2)
elif op == "-":
print(num1 - num2)
elif op == "/":
print(num1 / num2)
elif op == "*":
print(num1 * num2)
else:
print("Invalid operator")