Advertisement
michael_xgrind

Untitled

Dec 4th, 2014
211
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.63 KB | None | 0 0
  1. # Funcao
  2. def soma(a,b):
  3.     return a+b
  4.    
  5. def menos(a,b):
  6.     return a-b
  7.    
  8. def vezes(a,b):
  9.     return a*b
  10.  
  11. # Variaveis
  12. num = []
  13.  
  14. # Laco
  15. for i in range(1,3):
  16.     n = int(raw_input('Entre com o numero %d: ' % i))
  17.     num.append(n) # adiciona o valor a lista
  18.  
  19. resp = int(raw_input('\nO que deseja fazer? (1 - Soma / 2 - Menos / 3 - Vezes)\n-> '))
  20.  
  21. # Desvio Condicional
  22. if resp == 1:
  23.     print '\n%d + %d = %d' % (num[0],num[1],soma(num[0],num[1]))
  24. elif resp == 2:
  25.     print '\n%d - %d = %d' % (num[0],num[1],menos(num[0],num[1]))
  26. elif resp == 3:
  27.     print '\n%d * %d = %d' % (num[0],num[1],vezes(num[0],num[1]))
  28. else:
  29.     print '\nFuncao invalida!'
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement