Skip to content

Instantly share code, notes, and snippets.

@juanpabloaj
Created June 21, 2012 13:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save juanpabloaj/2965892 to your computer and use it in GitHub Desktop.
Save juanpabloaj/2965892 to your computer and use it in GitHub Desktop.
python captura de entrada
#!/usr/bin/python
# -*- coding: utf-8 -*-
# escoger opcion
def opciones():
print 's : sumar'
print 'r : restar'
print 'q : salir'
while True:
print
opciones()
o = raw_input('Ingrese opcion: ')
if o == 's' or o == 'r':
x = raw_input('Ingrese primer numero: ')
y = raw_input('Ingrese segundo numero: ')
x = int(x)
y = int(y)
if o == 's':
print x, '+', y, ' = ', x+y
elif o == 'r':
print x, '-', y, ' = ', x-y
elif o == 'q':
break
else:
print "Opcion desconocida"
#!/usr/bin/python
# -*- coding: utf-8 -*-
# una operacion sobre dos numeros
print "Ingrese dos numeros"
x = raw_input('Ingrese primer numero: ')
y = raw_input('Ingrese segundo numero: ')
# sin int se consideran string y se concatenan
x = int(x)
y = int(y)
print x, '+', y, ' = ', x+y
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment