Created
June 21, 2012 13:57
-
-
Save juanpabloaj/2965892 to your computer and use it in GitHub Desktop.
python captura de entrada
This file contains 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
#!/usr/bin/python | |
# -*- coding: utf-8 -*- | |
# escoger opcion | |
def opciones(): | |
print 's : sumar' | |
print 'r : restar' | |
print 'q : salir' | |
while True: | |
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" |
This file contains 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
#!/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