mirror of
https://github.com/venomade/calculator.git
synced 2026-11-16 18:27:39 +00:00
Add interactive prompt loop
This commit is contained in:
1 parent
04359ef139
commit
8123aa5aa9
1 file changed
+19
@@ -9,3 +9,22 @@ def multiply(a, b):
|
||||
|
||||
def divide(a, b):
|
||||
return a / b
|
||||
|
||||
def main():
|
||||
while True:
|
||||
a = float(input("First number: "))
|
||||
op = input("Operator (+ - * /): ")
|
||||
b = float(input("Second number: "))
|
||||
if op == "+":
|
||||
print("Result:", add(a, b))
|
||||
elif op == "-":
|
||||
print("Result:", subtract(a, b))
|
||||
elif op == "*":
|
||||
print("Result:", multiply(a, b))
|
||||
elif op == "/":
|
||||
print("Result:", divide(a, b))
|
||||
else:
|
||||
print("Unknown operator:", op)
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Reference in new issue
Block a user