From 477cbcc52eb5f8df6226707f760ae090cab7da35 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Laura=20=C3=81lvarez?= Date: Mon, 16 Oct 2017 16:27:43 -0500 Subject: [PATCH] Add python language: hello-world, arrays, i-o, vector --- langs/Python/arrays | 4 ++++ langs/Python/hello-world | 1 + langs/Python/input-output | 7 +++++++ langs/Python/vector | 14 ++++++++++++++ 4 files changed, 26 insertions(+) create mode 100644 langs/Python/arrays create mode 100644 langs/Python/hello-world create mode 100644 langs/Python/input-output create mode 100644 langs/Python/vector diff --git a/langs/Python/arrays b/langs/Python/arrays new file mode 100644 index 0000000..390f3cf --- /dev/null +++ b/langs/Python/arrays @@ -0,0 +1,4 @@ +a = [None] * 100 # Creación +b = [1,2,3,4,5] # Creación con inicialización + +a[5] = 34; # Acceso y modificación diff --git a/langs/Python/hello-world b/langs/Python/hello-world new file mode 100644 index 0000000..0aaad6a --- /dev/null +++ b/langs/Python/hello-world @@ -0,0 +1 @@ +print "Hola mundo" diff --git a/langs/Python/input-output b/langs/Python/input-output new file mode 100644 index 0000000..2461dd0 --- /dev/null +++ b/langs/Python/input-output @@ -0,0 +1,7 @@ +a = int(raw_input("Ingrese numero: ")) # Lee un entero +b = raw_input("Ingrese string: ") # Lee un string +# En python, siempre se lee toda la línea + +# Salida de datos +print "Sin salto de linea" +print "Con salto de linea\n" diff --git a/langs/Python/vector b/langs/Python/vector new file mode 100644 index 0000000..317a4b7 --- /dev/null +++ b/langs/Python/vector @@ -0,0 +1,14 @@ +# Declaración e inicialización +a = [] +# Inserción +a.append(32) +# Obtener valor en un índice dado +a[1] +# Modificar el elemento dado(0) con el valor dado(25) +a[0] = 25 +# Borrar valor en un índice dado +del a[1] +# Borrar todo +del a[:] +# Obtener tamaño +len(a)