-
Notifications
You must be signed in to change notification settings - Fork 0
/
"simple"-calculator.py
99 lines (88 loc) · 2.21 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
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
import time
print('Hello!')
print(' ')
time.sleep(.5)
print('Welcome to the Calculator!')
print(' ')
i = '0'
i2 = 'y'
tupley = 'y'
tuplen = 'n'
tupleopadd = ('Add','add','+')
tupleopsubtract = ('Subtract','subtract','minus','Minus','-')
tupleopmult = ('Multiply','multiply','X','x','*')
tupleopdivide = ('Divide','divide','/','÷')
op = '0'
num1 = int(0)
num2 = int(0)
x = int(0)
time.sleep(1)
while i == 'n' or '0':
if i2 == 'n':
i = input('Are you sure?(y/n): ')
if i == 'y':
break
elif i == 'n':
i2 = 'y'
continue
elif i2 == 'y':
print(' ')
num1 = int(input('Enter the first number: '))
print(' ')
time.sleep(.4)
num2 = int(input('Enter the second number: '))
print(' ')
time.sleep(.4)
while i2 == '0' or 'y':
op = input('What Operation would you like to preform?(+ - * ÷): ')
print(' ')
print(' ')
if op in tupleopadd:
x = int(num1)+int(num2)
print('The result is:', x)
print(' ')
time.sleep(1)
i2 = input('Would you like to calculate anything else?(y/n): ')
if i2 == 'n':
i = 'n'
break
elif i2 == 'y':
break
elif op in tupleopsubtract:
x = int(num1)-int(num2)
print('The result is:', x)
print(' ')
time.sleep(1)
i2 = input('Would you like to calculate anything else?(y/n): ')
if i2 == 'n':
i = 'n'
break
elif i2 == 'y':
break
elif op in tupleopmult:
x = int(num1)*int(num2)
print('The result is:', x)
print(' ')
time.sleep(1)
i2 = input('Would you like to calculate anything else?(y/n): ')
if i2 == 'n':
i = 'n'
break
elif i2 == 'y':
break
elif op in tupleopdivide:
x = int(num1)/int(num2)
print('The result is:', x)
print(' ')
time.sleep(1)
i2 = input('Would you like to calculate anything else?(y/n): ')
if i2 == 'n':
i = 'n'
break
elif i2 == 'y':
break
else:
print('Invalid Operation: Please Try Again')
print(' ')
time.sleep(1)
continue