Created
May 3, 2012 05:28
-
-
Save yesidays/2583486 to your computer and use it in GitHub Desktop.
Primeros pasos Python
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
print "Hola Mundo" | |
#Numeros hexadecimales anteponiendo 0x | |
hexa = 0xA | |
print hexa | |
#Numeros octales anteponiendo un 0 | |
octal = 010 | |
print octal | |
#Creando una lista | |
lista = [10, 15, "Texto", True] | |
print lista | |
#Diccionarios, colecciones que relacionan una clave y un valor. | |
extensiones = {"PHP" : ".php", "Python" : ".py", "NodeJs" : ".js"} | |
#Si deseamos saber la extension para Python escribimos | |
print extensiones["Python"] | |
#Condiciones | |
twitter = "silvercorp" | |
if twitter == "silvercorp": | |
print "Mi cuenta personal es @" + twitter | |
else: | |
print "Visita @codejobs" | |
#Condiciones | |
status = "que cosa?" | |
if status == "siguiendo": | |
print "Gracias ;) espero @codejobs sea de utilidad" | |
elif status == "que cosa?": | |
print "Te invito a que nos sigas en @codejobs" | |
else: | |
print "Entonces :) a @silvercorp" | |
#Ciclos | |
i = 0 | |
while i < 5: | |
i = i + 1 | |
print "Numero " + str(i) | |
#For | |
lenguajes = ["php", "javascript", "c", "c#"] | |
for data in lenguajes: | |
print "-> " + data | |
#Declarando funciones | |
def suma(dato1, dato2): | |
print dato1 + dato2 | |
def desplegar(cadena, numero): | |
print numero * cadena | |
suma(10,5) | |
desplegar(" :) ",5) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment