-
Notifications
You must be signed in to change notification settings - Fork 0
/
simple-calculator.py
39 lines (36 loc) · 1.22 KB
/
simple-calculator.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# Simple Calculator - A simple calculator program
# Copyright (c) 2020 Ercan Ersoy
# This file licensed under MIT License.
while True:
print("1. Addition")
print("2. Substraction")
print("3. Multiplication")
print("4. Division")
print("5. Exit")
choice = input("Your choice: ")
print()
if choice == "1":
first_addend = float(input("First addend: "))
second_addend = float(input("Second addend: "))
print("Result: ", end="")
print(first_addend + second_addend)
elif choice == "2":
first_subtrahend = float(input("First subtrahend: "))
second_subtrahend = float(input("Second subtrahend: "))
print("Result: ", end="")
print(first_subtrahend - second_subtrahend)
elif choice == "3":
multiplier = float(input("Multiplier: "))
multiplicand = float(input("Multiplicand: "))
print("Result: ", end="")
print(multiplier * multiplicand)
elif choice == "4":
dividend = float(input("Dividend: "))
divider = float(input("Divider: "))
print("Result: ", end="")
print(dividend / divider)
elif choice == "5":
break
else:
print("Wrong choice!")
print()