Created
July 18, 2012 16:04
-
-
Save ramalho/3137159 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # coding: utf-8 | |
| from operator import add, sub, mul, div | |
| operadores = {'+': add, '-': sub, '*':mul, '/':div} | |
| x = input('Entre com o operando 1: ') | |
| y = input('Entre com o operando 1: ') | |
| operacao = raw_input('Entre com a operação: ') | |
| operador = operadores.get(operacao) | |
| if operador: | |
| resultado = operador(x, y) | |
| print 'Resultado:', resultado | |
| else: | |
| print 'Operação inválida' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment