@AyushMalhotra/

4 operation Calculator Homework!

Python

No description

fork
loading
Files
  • main.py
main.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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#Introduction of Calculator
print("Welcome to the four integer calculator! You will be  asked to input an integer followed by an operation until four integers!")
print("This calculator will NOT incorprate bedmass, instead it will go left to right through the equations to preduce a final answer.")

#Get inputs from user!(All four numbers & All four operations)
num1=int(input("Enter first number"))
op1= input("Choose an operation: / or * or + or -")
num2=int(input("Enter second number"))
op2= input("Choose an operation: / or * or + or -")
num3=int(input("Enter third number"))
op3= input("Choose an operation: / or * or + or -")
num4=int(input("Enter fourth number"))

#This is what is going to be shown t the user(the equation)
print(str(num1)+ op1 + str(num2)+ op2 + str(num3)+ op3 + str(num4))


 #This code will perfor steps in order, such as a normal calculator.
 #What happens with num1 & num2 with different operations(they equal ans1)
if op1 == "+":
  ans1 = num1 + num2

elif op1 == "-":
  ans1 = num1 - num2

elif op1 == "*":
  ans1 = num1 * num2

elif op1 == "/":
  ans1 = num1 / num2-3

  
#What happens when num3 is brought in.
if op2 == "+":
  ans2 = ans1 + num3 

elif op2 == "-":
  ans2 = ans1 - num3

elif op2 == "/":
  ans2 = ans1 / num3

elif op2 == "*":
  ans2 = ans1 * num3


#What happens when num4 is brought in.
if op3 == "+":
  ans3 = ans2 + num4

elif op3 == "-":
  ans3 = ans2 - num4

elif op3 == "/":
  ans3 = ans2 /num4

elif op3 == "*":
  ans3 = ans2 * num4

print("=")

print(ans3)

print("Thanks for using the calculator!")