Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Funcao
- def soma(a,b):
- return a+b
- def menos(a,b):
- return a-b
- def vezes(a,b):
- return a*b
- # Variaveis
- num = []
- # Laco
- for i in range(1,3):
- n = int(raw_input('Entre com o numero %d: ' % i))
- num.append(n) # adiciona o valor a lista
- resp = int(raw_input('\nO que deseja fazer? (1 - Soma / 2 - Menos / 3 - Vezes)\n-> '))
- # Desvio Condicional
- if resp == 1:
- print '\n%d + %d = %d' % (num[0],num[1],soma(num[0],num[1]))
- elif resp == 2:
- print '\n%d - %d = %d' % (num[0],num[1],menos(num[0],num[1]))
- elif resp == 3:
- print '\n%d * %d = %d' % (num[0],num[1],vezes(num[0],num[1]))
- else:
- print '\nFuncao invalida!'
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement