-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcalculator-gpt.py
More file actions
37 lines (34 loc) · 1.11 KB
/
calculator-gpt.py
File metadata and controls
37 lines (34 loc) · 1.11 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
def main():
name = input('What is your first an second name?').strip().title
while True:
a = float(input('What is the first number?', name))
b = float(input('What is the second number?', name))
question = input('What do you want to do with those two numbers?',name).lower().strip()
if question == '+':
print(a + b)
elif question == '-':
print(a - b)
elif question == '*':
print(a * b)
elif question == '/':
if b == 0:
print('Please enter a valid number')
else:
print(a / b)
elif question == '//':
if b == 0:
print('Please enter a valid number')
else:
print(a // b)
elif question == '%':
if b == 0:
print('Please enter a valid number')
else:
print(a % b)
else:
print('Enter a valid operator')
again = input('Would you like to continue? [yes/no]')
if again != 'yes':
print('Goodbye')
break
main()