diegoxter

calculadora0.2.py

Aug 10th, 2011
178
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.15 KB | None | 0 0
  1. # -*- coding: utf-8 -*-
  2.  
  3. def menu():
  4.     print '''¿Que quieres hacer?
  5.            a)Sumar             b)Restar
  6.            c)Multiplicar       d)Dividir
  7.                        e)Salir
  8.                        '''
  9. def asknumbers():
  10.         a = float(raw_input('Un numerito pues: '))
  11.         b = float(raw_input('Y el otro?: '))
  12.         return a, b
  13.  
  14. opcion = 0
  15. while opcion != 'e':
  16.     menu()
  17.     opcion = raw_input('Que vas a hacer? ')
  18.     if opcion == 'e':
  19.         print 'Nos vemos!'
  20.     elif opcion != 'a' and opcion != 'b' and opcion != 'c' and opcion != 'd' and opcion != 'e':
  21.         print '''
  22. *************************************
  23.        Eso no es una opcion valida! |
  24. *************************************'''
  25.         print
  26.     else:
  27.         a, b = asknumbers()
  28.     if opcion == 'a':
  29.         resultado = int(a+b)
  30.         print '''
  31. ------------------------------
  32.        El resultado es''', resultado
  33.         print '------------------------------'
  34.         opcion = 0
  35.     elif opcion == 'b':
  36.         resultado = int(a-b)
  37.         print '''
  38. ------------------------------
  39.        El resultado es''', resultado
  40.         print '------------------------------'
  41.         opcion = 0
Advertisement
Add Comment
Please, Sign In to add comment