-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
63 lines (53 loc) · 1.79 KB
/
Copy pathmain.py
File metadata and controls
63 lines (53 loc) · 1.79 KB
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
print()
print("Welcome to the Simple Calculator!")
print("=================================")
print()
#Loop so user can do as many calcualtions as needed
while True:
#Get input from user
num1 = float(input("Enter your first value: "))
num2 = float(input("Enter your second value: "))
#Let user pick operation
print()
print("OPERATIONS AVAILABLE")
print("=================================")
print()
print("1. Addition")
print("2. Subtraction")
print("3. Multiplication")
print("4. Division")
print("5. Modulo")
print()
option = int(input("Enter the value that corresponds to the operation you would like to complete: "))
if option == 1:
sum = num1 + num2
print(f"The sum of {num1} and {num2} is {sum}.")
elif option == 2:
difference = num1 - num2
print(f"The difference between {num1} and {num2} is {difference}.")
elif option == 3:
product = num1 * num2
print(f"The product of {num1} and {num2} is {product}")
elif option == 4:
quotient = num1 / num2
print(f"The quotient of {num1} and {num2} is {quotient}.")
elif option == 5:
remainder = num1 % num2
print(f"The remainder given when dividing {num1} and {num2} is {remainder}.")
else:
print()
print("ERROR: Please enter a valid number.")
#Check to see if user wants to keep calculating
print()
choice = input("Would you like to do another calculation? Enter yes or no: ").strip().lower()
print()
print("=================================")
if choice == 'yes' or choice == 'y':
print()
print("Starting a new calculation...")
print()
else:
print()
print("THANK YOU FOR USING SIMPLE CALCULATOR!")
print()
break