-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCalculator.py
More file actions
25 lines (24 loc) · 813 Bytes
/
Calculator.py
File metadata and controls
25 lines (24 loc) · 813 Bytes
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
def calculator():
operation = input('Qual é a operação? + , - , * ou / ?: ')
num1 = int(input('Primeiro numero: '))
num2 = int(input('Segundo numero: '))
if operation == '+':
print('{} + {} ='.format(num1, num2), num1 +num2)
elif operation == '-':
print('{} - {} ='.format(num1, num2), num1 - num2)
elif operation == '*':
print('{} * {} ='.format(num1, num2), num1 *num2)
elif operation == '/':
print('{} / {} ='.format(num1, num2), num1 /num2)
else:
print('Operação inexistente.')
again()
def again():
novamente = input('Quer calcular novamente? Y para sim, N para não.')
if novamente.upper() == "Y":
calculator()
elif novamente.upper() =="N":
print('Sayonara.')
else:
again()
calculator()