repl.it
@nickbeattie/

trying to make the working one work betterer

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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
numbers = input("How many numbers do you have?")
add_ops = ["adding", "add","+", "addition", "Add", "Adding", "Addition"]
subtract_ops = ["-", "minus" , "subtract", "subtraction", "subtracting", "Minus", "Subtract", "Subtraction", "Subtracting"]
multiply_ops = ["*", "x", "multiply", "multiplication", "multiplying", "Multiply", "Multiplication", "Multiplying"]
divide_ops = ["/", "÷", "divide", "division", "dividing", "Divide", "Dividing", "Division"]
if numbers == "2":
  def add(x, y):
    return x + y
  def subtract(x, y):
    return x - y
  def multiply(x, y):
    return x * y
  def divide(x, y):
    return x / y
  num1 = int(input("What is your first number?"))
  op1 = input("What is your operation?")
  num2 = int(input("What is your second number?"))
  if op1 in add_ops:
    print(num1, "+", num2, "=", add(num1, num2))
  elif op1 in subtract_ops:
    print(num1, "-", num2, "=", subtract(num1,num2))
  elif op1 in multiply_ops:
    print(num1, "*", num2, "=", multiply(num1, num2))
  elif op1 in divide_ops:
    print(num1, "÷", num2, "=", divide(num1, num2))
  else:
    print("Invalid operation")
if numbers == "3":
  def add(x, y, z):
    return x + y + z
  def subtract(x, y, z):
    return x - y - z
  def multiply(x, y, z):
    return x * y * z
  def divide(x, y, z):
    return x / y / z
  num1 = int(input("What is your first number?"))
  op1 = input("What is your first operation?")
  num2 = int(input("What is your second number?"))
  op2 = input("What is your second operation?")
  num3 = int(input("What is your third number?"))
  if op1 in add_ops:
    def add2(x, y):
      return x + y
    def subtract2(x, y):
      return x - y
    def multiply2(x, y):
      return x * y
    def divide2 (x, y):
      return x / y
    if op2 in add_ops:
      answer = (add2(num1, num2))
      print(num1, "+", num2, "+", num3, "=", add2(answer, num3))
    elif op2 in subtract_ops:
      answer = (add2(num1, num2))
      print(num1, "+", num2, "-", num3, "=", subtract2(answer, num3))
    elif op2 in multiply_ops:
      answer = (add2(num1, num2))
      print(num1, "+", num2, "*", num3, "=", multiply2(answer, num3))
    elif op2 in divide_ops:
      answer = (add2(num1, num2))
      print(num1, "+", num2, "÷", num3, "=", divide2(answer, num3))
    else:
      print ("Invalid second operation")
  elif op1 in subtract_ops:
    def add2(x, y):
      return x + y
    def subtract2(x, y):
      return x - y
    def multiply2(x, y):
      return x * y
    def divide2 (x, y):
      return x / y
    if op2 in add_ops:
      answer = (subtract2(num1, num2))
      print(num1, "-", num2, "+", num3, "=", add2(answer, num3))
    elif op2 in subtract_ops:
      answer = (subtract2(num1, num2))
      print(num1, "-", num2, "-", num3, "=", subtract2(answer, num3))
    elif op2 in multiply_ops:
      answer = (subtract2(num1, num2))
      print(num1, "-", num2, "*", num3, "=", multiply2(answer, num3))
    elif op2 in divide_ops:
      answer = (subtract2(num1, num2))
      print(num1, "-", num2, "÷", num3, "=", divide2(answer, num3))
    else:
      print("Invalid second operation")
  elif op1 in multiply_ops:
    def add2(x, y):
      return x + y
    def subtract2(x, y):
      return x - y
    def multiply2(x, y):
      return x * y
    def divide2 (x, y):
      return x / y
    if op2 in add_ops:
      answer = (multiply2(num1, num2))
      print(num1, "*", num2, "+", num3, "=", add2(answer, num3))
    elif op2 in subtract_ops:
      answer = (multiply2(num1, num2))
      print(num1, "*", num2, "-", num3, "=", subtract2(answer, num3))
    elif op2 in multiply_ops:
      answer = (multiply2(num1, num2))
      print(num1, "*", num2, "*", num3, "=", multiply2(answer, num3))
    elif op2 in divide_ops:
      answer = (multiply2(num1, num2))
      print(num1, "*", num2, "÷", num3, "=", divide2(answer, num3))
    else:
      print("Invalid second operation")
  elif op1 in divide_ops:
    def add2(x, y):
      return x + y
    def subtract2(x, y):
      return x - y
    def multiply2(x, y):
      return x * y
    def divide2 (x, y):
      return x / y
    if op2 in add_ops:
      answer = (divide2(num1, num2))
      print(num1, "÷", num2, "+", num3, "=", add2(answer, num3))
    elif op2 in subtract_ops:
      answer = (divide2(num1, num2))
      print(num1, "÷", num2, "-", num3, "=", subtract2(answer, num3))
    elif op2 in multiply_ops:
      answer = (divide2(num1, num2))
      print(num1, "÷", num2, "*", num3, "=", multiply2(answer, num3))
    elif op2 in divide_ops:
      answer = (divide2(num1, num2))
      print(num1, "÷", num2, "÷", num3, "=", divide2(answer, num3))
    else:
      print("Invalid second operation")
  else:
    print("Invalid first operation")
if numbers == "4":
  def add(x, y, z, a):
    return x + y + z + a
  def subtract(x, y, z, a):
    return x - y - z - a
  def multiply(x, y, z, a):
    return x * y * z * a
  def divide(x, y, z, a):
    return x / y / z / a
  num1 = int(input("What is your first number?"))
  op1 = input("What is your first operation?")
  num2 = int(input("What is your second number?"))
  op2 = input("What is your second operation?")
  num3 = int(input("What is your third number?"))
  op3 = input("What is your third operation?")
  num4 = int(input("What is your fourth number?"))
if op1 in add_ops:
    def add2(x, y):
      return x + y
    def subtract2(x, y):
      return x - y
    def multiply2(x, y):
      return x * y
    def divide2 (x, y):
      return x / y
    if op2 in add_ops:
      if op3 in add_ops:
        answer = (add2(num1, num2))
        answer2 = (add2(num3, num4))
        print (num1,  
      answer = (add2(num1, num2))
      print(num1, "+", num2, "+", num3, "=", add2(answer, num3))
    elif op2 in subtract_ops:
      answer = (add2(num1, num2))
      print(num1, "+", num2, "-", num3, "=", subtract2(answer, num3))
    elif op2 in multiply_ops:
      answer = (add2(num1, num2))
      print(num1, "+", num2, "*", num3, "=", multiply2(answer, num3))
    elif op2 in divide_ops:
      answer = (add2(num1, num2))
      print(num1, "+", num2, "÷", num3, "=", divide2(answer, num3))
    else:
      print ("Invalid second operation")
  elif op1 in subtract_ops:
    def add2(x, y):
      return x + y
    def subtract2(x, y):
      return x - y
    def multiply2(x, y):
      return x * y
    def divide2 (x, y):
      return x / y
    if op2 in add_ops:
      answer = (subtract2(num1, num2))
      print(num1, "-", num2, "+", num3, "=", add2(answer, num3))
    elif op2 in subtract_ops:
      answer = (subtract2(num1, num2))
      print(num1, "-", num2, "-", num3, "=", subtract2(answer, num3))
    elif op2 in multiply_ops:
      answer = (subtract2(num1, num2))
      print(num1, "-", num2, "*", num3, "=", multiply2(answer, num3))
    elif op2 in divide_ops:
      answer = (subtract2(num1, num2))
      print(num1, "-", num2, "÷", num3, "=", divide2(answer, num3))
    else:
      print("Invalid second operation")
  elif op1 in multiply_ops:
    def add2(x, y):
      return x + y
    def subtract2(x, y):
      return x - y
    def multiply2(x, y):
      return x * y
    def divide2 (x, y):
      return x / y
    if op2 in add_ops:
      answer = (multiply2(num1, num2))
      print(num1, "*", num2, "+", num3, "=", add2(answer, num3))
    elif op2 in subtract_ops:
      answer = (multiply2(num1, num2))
      print(num1, "*", num2, "-", num3, "=", subtract2(answer, num3))
    elif op2 in multiply_ops:
      answer = (multiply2(num1, num2))
      print(num1, "*", num2, "*", num3, "=", multiply2(answer, num3))
    elif op2 in divide_ops:
      answer = (multiply2(num1, num2))
      print(num1, "*", num2, "÷", num3, "=", divide2(answer, num3))
    else:
      print("Invalid second operation")
  elif op1 in divide_ops:
    def add2(x, y):
      return x + y
    def subtract2(x, y):
      return x - y
    def multiply2(x, y):
      return x * y
    def divide2 (x, y):
      return x / y
    if op2 in add_ops:
      answer = (divide2(num1, num2))
      print(num1, "÷", num2, "+", num3, "=", add2(answer, num3))
    elif op2 in subtract_ops:
      answer = (divide2(num1, num2))
      print(num1, "÷", num2, "-", num3, "=", subtract2(answer, num3))
    elif op2 in multiply_ops:
      answer = (divide2(num1, num2))
      print(num1, "÷", num2, "*", num3, "=", multiply2(answer, num3))
    elif op2 in divide_ops:
      answer = (divide2(num1, num2))
      print(num1, "÷", num2, "÷", num3, "=", divide2(answer, num3))
    else:
      print("Invalid second operation")
  else:
    print("Invalid first operation")
Fetching token
?