diff --git a/.gitignore b/.gitignore index 5391d87..5bd7933 100644 --- a/.gitignore +++ b/.gitignore @@ -135,4 +135,5 @@ dmypy.json .pytype/ # Cython debug symbols -cython_debug/ \ No newline at end of file +cython_debug/ +.vscode/settings.json diff --git a/01_tipos_de_datos/01_booleanos/definicion.py b/01_tipos_de_datos/01_booleanos/definicion.py new file mode 100644 index 0000000..0464f71 --- /dev/null +++ b/01_tipos_de_datos/01_booleanos/definicion.py @@ -0,0 +1,10 @@ +""" +@author taicoding +Declaremos variables de tipo booleano +""" +verdad = True +print(verdad) +# Resultado: True +falso = False +print(falso) +# Resultado: False diff --git a/01_tipos_de_datos/01_booleanos/mini_test.py b/01_tipos_de_datos/01_booleanos/mini_test.py new file mode 100644 index 0000000..27adb0f --- /dev/null +++ b/01_tipos_de_datos/01_booleanos/mini_test.py @@ -0,0 +1,8 @@ +""" +@author taicoding +Tema: Booleanos +¿Cuál es el resultado? 👩🏻‍🏫👩🏻‍💻 +""" +p = True +q = False +print(not q and (q or p)) diff --git a/01_tipos_de_datos/01_booleanos/operadores.py b/01_tipos_de_datos/01_booleanos/operadores.py new file mode 100644 index 0000000..a141da4 --- /dev/null +++ b/01_tipos_de_datos/01_booleanos/operadores.py @@ -0,0 +1,15 @@ +""" +@author taicoding +Usemos los operadores lógicos 👩🏻‍🏫 +""" +verdad = True +falso = False +# Negación +print(not verdad) +# Resultado: False +# Conjunción u operador 'y' +print(verdad and falso) +# Resultado: False +# Disyunción u operador 'o' +print(verdad or falso) +# Resultado: True diff --git a/01_tipos_de_datos/02_numeros/01_enteros/definicion.py b/01_tipos_de_datos/02_numeros/01_enteros/definicion.py new file mode 100644 index 0000000..b6711b0 --- /dev/null +++ b/01_tipos_de_datos/02_numeros/01_enteros/definicion.py @@ -0,0 +1,10 @@ +""" +@author taicoding +Declaremos variables de tipo entero +""" +edad = 28 +print(edad) +# Resultado: 28 +ahorros = -125 +print(ahorros) +# Resultado: -125 diff --git a/01_tipos_de_datos/02_numeros/02_punto_flotante/definicion.py b/01_tipos_de_datos/02_numeros/02_punto_flotante/definicion.py new file mode 100644 index 0000000..9ab0c70 --- /dev/null +++ b/01_tipos_de_datos/02_numeros/02_punto_flotante/definicion.py @@ -0,0 +1,11 @@ +""" +@author taicoding +Declaremos variables numericas +de punto flotante +""" +pi = 3.141592653589793 +print(pi) +# Resultado: 3.141592653589793 +latitud = -19.0206372 +print(latitud) +# Resultado: -19.0206372 diff --git a/01_tipos_de_datos/02_numeros/03_operaciones_numericas/operacionesSimples_I.py b/01_tipos_de_datos/02_numeros/03_operaciones_numericas/operacionesSimples_I.py new file mode 100644 index 0000000..a030b4a --- /dev/null +++ b/01_tipos_de_datos/02_numeros/03_operaciones_numericas/operacionesSimples_I.py @@ -0,0 +1,17 @@ +""" +@author taicoding +Operadores aritmeticos Parte I +""" +# Definimos las variables con las que realizaremos +# las operaciones aritmeticas +a, b = 8, 3 +# La adiccion o suma se realiza con +# el operador '+' +suma = a + b +print(suma) +# Resultado: 11 +# La sustraccion o resta se realiza con +# el operador '-' +resta = a - b +print(resta) +# Resultado: 5 diff --git a/OperacionesNumericas/OperacionesSimples_II.py b/01_tipos_de_datos/02_numeros/03_operaciones_numericas/operacionesSimples_II.py similarity index 100% rename from OperacionesNumericas/OperacionesSimples_II.py rename to 01_tipos_de_datos/02_numeros/03_operaciones_numericas/operacionesSimples_II.py diff --git a/OperacionesNumericas/Operadores_III.py b/01_tipos_de_datos/02_numeros/03_operaciones_numericas/operadores_III.py similarity index 100% rename from OperacionesNumericas/Operadores_III.py rename to 01_tipos_de_datos/02_numeros/03_operaciones_numericas/operadores_III.py diff --git a/01_tipos_de_datos/02_numeros/mini_test.py b/01_tipos_de_datos/02_numeros/mini_test.py new file mode 100644 index 0000000..70b7c29 --- /dev/null +++ b/01_tipos_de_datos/02_numeros/mini_test.py @@ -0,0 +1,9 @@ +""" +@author taicoding +Tema: Operadores aritméticos +¿Cuál es el resultado? 👩🏻‍🏫👩🏻‍💻🐍 +""" +a = 5 +b = 7 +r = a + b ** 2 - b // a +print(r) diff --git a/01_tipos_de_datos/02_numeros/operaciones_aritmeticas.py b/01_tipos_de_datos/02_numeros/operaciones_aritmeticas.py new file mode 100644 index 0000000..8fa3cc5 --- /dev/null +++ b/01_tipos_de_datos/02_numeros/operaciones_aritmeticas.py @@ -0,0 +1,19 @@ +""" +@author taicoding +Usemos los operadores aritméticos 👩🏻‍🏫👩🏻‍💻🐍 +""" +a, b = 3, 2 +print("Exponenciación:", a ** b) +# Exponenciación: 9 +print("Multiplicación:", a * b) +# Multiplicación: 6 +print("División:", a / b) +# División: 1.5 +print("División entera:", a // b) +# División entera: 1 +print("Modulo:", a % b) +# Modulo: 1 +print("Adición:", a + b) +# Adición: 5 +print("Sustracción:", a - b) +# Sustracción: 1 diff --git a/01_tipos_de_datos/03_cadenas/definicion.py b/01_tipos_de_datos/03_cadenas/definicion.py new file mode 100644 index 0000000..74d6f48 --- /dev/null +++ b/01_tipos_de_datos/03_cadenas/definicion.py @@ -0,0 +1,28 @@ +""" +@author taicoding +Declaremos variables de tipo cadena +""" +# Comillas simples +simple = "Soy una cadena uwu" +print(simple) +# Resultado: Soy una cadenas +# Comillas dobles +doble = "Una secuencia de caracteres" +print(doble) +# Resultado: Una secuencia de caracteres +# Metodo de cadena +metodo = str("Soy inmutable uwu") +print(metodo) +# Resultado: Soy inmutable uwu +# Multiples lineas +multilinea = """Puedes declararme +de varias formas +owo uwu awa""" +print(multilinea) +# Resultado: Puedes declararme +# de varias formas +# owo uwu awa +# Concatenación +concatenando = "¡Python" + " es cool!" +print(concatenando) +# Resultado: ¡Python es cool! diff --git a/01_tipos_de_datos/03_cadenas/mini-test.py b/01_tipos_de_datos/03_cadenas/mini-test.py new file mode 100644 index 0000000..13e5e79 --- /dev/null +++ b/01_tipos_de_datos/03_cadenas/mini-test.py @@ -0,0 +1,7 @@ +""" +@author taicoding +Tema: Cadenas +¿Cuál es el resultado? 👩🏻‍🏫👩🏻‍💻🐍 +""" +cadena = "Python \nis \nCool!" +print(cadena) diff --git a/01_tipos_de_datos/resumen.py b/01_tipos_de_datos/resumen.py new file mode 100644 index 0000000..b0bb558 --- /dev/null +++ b/01_tipos_de_datos/resumen.py @@ -0,0 +1,14 @@ +""" +@author taicoding +¿Cómo definir variables en Python? 🐍👩🏻‍🏫👩🏻‍💻 +Primero le damos un nombre a la variable +y luego le asignamos un valor. +""" +# El valor puede ser booleano +estudiante = False +# El valor puede ser un número entero +edad = 29 +# El valor puede ser un número con parte decimal +estatura = 1.65 +# El valor pude ser una cadena +nombre = "Tatiana" diff --git a/02_estructuras_de_datos/01_listas/definicion.py b/02_estructuras_de_datos/01_listas/definicion.py new file mode 100644 index 0000000..88fad09 --- /dev/null +++ b/02_estructuras_de_datos/01_listas/definicion.py @@ -0,0 +1,14 @@ +""" +@author taicoding +Formas de declarar una lista +""" + +# Sin elementos +likes = [] +seguidores = list() +# Con elementos +letras = list(["P", "Y", "T", "H", "O", "N", 3.9, True]) +emociones = ["😌", "😖", "🤩", "😐"] +# Bonus: ✨ Veamos el tipo ✨ +print(type(emociones)) +# R: diff --git a/02_estructuras_de_datos/01_listas/metodos.py b/02_estructuras_de_datos/01_listas/metodos.py new file mode 100644 index 0000000..f023475 --- /dev/null +++ b/02_estructuras_de_datos/01_listas/metodos.py @@ -0,0 +1,52 @@ +""" +@author taicoding +Métodos para agregar elementos a una Lista 🐍📜 +""" + +# Declaramos una lista de emociones +emociones = ["😊"] +# 📂 Agregar una nueva emoción al final de la lista +# Método: append(elemento) +emociones.append("😢") +print(emociones) +# 🖨️ Resultado: ['😊', '😢'] +# 📂 Agregar una nueva emoción en una posición +# especifica de la lista +# Método: insert(posición,elemento) +emociones.insert(1, "😵") +print(emociones) +# 🖨️ Resultado: ['😊', '😵', '😢'] +# 🧩 Agregar emociones utilizando otro iterable +# Un iterable puede ser una lista, tupla, cadena, etc. +# Método: extend(lista) +emociones.extend({"😄", "😍"}) +print(emociones) +# 🖨️ Resultado: ['😊', '😵', '😢', '😍', '😄'] +# 🧩 Agregar una emoción concatenando dos listas +emociones = emociones + ["😢"] +print(emociones) +# 🖨️ Resultado: ['😊', '😵', '😢', '😍', '😄', '😢'] +# ⭐️ Tip: El método append es el mas rápido + +# Declaramos una lista de emociones +emociones = ["😊", "😵", "😍", "😄", "😢"] +# 🗑️ Remover un elemento de la Lista +# Método: remove(elemento) +emociones.remove("😢") +print(emociones) +# 🖨️ Resultado: ['😊', '😵', '😍', '😄'] +# 🔄 Revertir los elementos de la Lista +# Método: reverse() +emociones.reverse() +print(emociones) +# 🖨️ Resultado: ['😄', '😍', '😵', '😊'] +# 📊 Ordenar los elementos de la Lista +# Método: sort() +emociones.sort() +print(emociones) +# 🖨️ Resultado: ['😄', '😊', '😍', '😵'] +# 🔍 Obtener el indice de un elemento +# Método: index(elemento) +indice = emociones.index("😍") +print(indice) +# 🖨️ Resultado: 2 diff --git a/02_estructuras_de_datos/01_listas/mini_test.py b/02_estructuras_de_datos/01_listas/mini_test.py new file mode 100644 index 0000000..e3c491e --- /dev/null +++ b/02_estructuras_de_datos/01_listas/mini_test.py @@ -0,0 +1,8 @@ +""" +@author taicoding +Tema: Listas 📋 +¿Cuál es el resultado? 👩🏻‍🏫👩🏻‍💻🐍 +""" + +python = [1, 2, 3, 4, 5, 6] +print(python[2:5]) diff --git a/02_estructuras_de_datos/02_conjuntos/definicion.py b/02_estructuras_de_datos/02_conjuntos/definicion.py new file mode 100644 index 0000000..f626d13 --- /dev/null +++ b/02_estructuras_de_datos/02_conjuntos/definicion.py @@ -0,0 +1,13 @@ +""" +@author taicoding +Formas de declarar un set 🐍 +""" +# Sin elementos +numeros = {} +verduras = set() +# Con elementos +frutas = set(["pera", "uva", "sandia"]) +pares = {22, 44, 66, 88, 100} +# Bonus: ✨ Veamos el tipo ✨ +print(type(verduras)) +# R: diff --git a/02_estructuras_de_datos/02_conjuntos/metodos.py b/02_estructuras_de_datos/02_conjuntos/metodos.py new file mode 100644 index 0000000..32f372e --- /dev/null +++ b/02_estructuras_de_datos/02_conjuntos/metodos.py @@ -0,0 +1,27 @@ +""" +@author taicoding +Métodos de Conjuntos 🐍🍟 +""" + +# Definimos un conjunto de frutas +frutas = {"🍓", "🍉"} +# 🧩 Agregar un elemento al conjunto +# Método: add(elemento) +frutas.add("🍋") +print(frutas) +# 🖨️ Resultado: {'🍋', '🍓', '🍉'} +# 🗑️ Remover un elemento al conjunto +# Método: discard(elemento) +frutas.discard("🍋") +print(frutas) +# 🖨️ Resultado: {'🍓', '🍉'} +# 🔗 Encontrar la diferencia entre dos conjuntos +# Método: difference(set) +bayas = {"🍓", "🍒"} +print(bayas.difference(frutas)) +# 🖨️ Resultado: {"🍒"} +# 🔘 Unir dos conjuntos +# Método: union(set) +frutas = frutas.union(bayas) +print(frutas) +# 🖨️ Resultado: {'🍒', '🍓', '🍉'} diff --git a/02_estructuras_de_datos/02_conjuntos/mini_test.py b/02_estructuras_de_datos/02_conjuntos/mini_test.py new file mode 100644 index 0000000..02e079a --- /dev/null +++ b/02_estructuras_de_datos/02_conjuntos/mini_test.py @@ -0,0 +1,10 @@ +""" +@author taicoding +Tema: Sets 🐍🍟 +¿Cuál es el resultado? 👩🏻‍🏫👩🏻‍💻🐍 +""" + +multiplos = {3, 6, 9, 12} +impares = {1, 3, 5, 7, 9} +resultado = multiplos.intersection(impares) +print(resultado) diff --git a/02_estructuras_de_datos/03_diccionarios/definicion.py b/02_estructuras_de_datos/03_diccionarios/definicion.py new file mode 100644 index 0000000..bac5f7e --- /dev/null +++ b/02_estructuras_de_datos/03_diccionarios/definicion.py @@ -0,0 +1,17 @@ +""" +@author taicoding +Formas de declarar un diccionario 🐍 +""" +# Sin elementos +recetas = {} +menu = dict() +# Con elementos +diccionario = dict({"llave": "valor"}) +cafeteria = { + "bebidas": ["café", "té", "jugo"], + "mesas": 5, +} +# Bonus: ✨ Veamos el tipo ✨ +print(type(menu)) +# R: +# Tip: La llave siempre es una cadena diff --git a/02_estructuras_de_datos/03_diccionarios/metodos.py b/02_estructuras_de_datos/03_diccionarios/metodos.py new file mode 100644 index 0000000..9e0f0eb --- /dev/null +++ b/02_estructuras_de_datos/03_diccionarios/metodos.py @@ -0,0 +1,71 @@ +""" +@author taicoding +Métodos de Diccionarios 🐍 +""" + +# Diccionario inicial +persona = dict({"nombre": "taicoding"}) +# ⭐️ Agregar elementos ⭐️ +persona.update({"edad": 27}) +print(persona) +# R: {'nombre': 'taicoding', +# 'edad': 27} +# ⭐️ Agregar elementos ⭐️ +persona["alergias"] = ["almendras"] +print(persona) +# R: {'nombre': 'taicoding', +# 'edad': 27, +# 'alergias': ['almendras']} + +# ⭐️ Remover un elemento especifico ⭐️ +persona.pop("alergias") +print(persona) +# R: {'nombre': 'taicoding', +# 'edad': 27} + +# ⭐️ Obtener el valor de una llave ⭐️ +edad = persona["edad"] +print(edad) +# R: 27 +edad = persona.get("edad") +print(edad) +# R: 27 + +# ⭐️ Obtener el valor de una llave ⭐️ +# Si la llave no existe regresa +# un valor por defecto +alergia = persona.setdefault("alergias", "ninguna") +print(alergia) +# R: ninguna +# ⭐️ Obtener una lista de las llaves ⭐️ +llaves = persona.keys() +print(llaves) +# R: dict_keys(['nombre', 'edad']) + +# ⭐️ Obtener una lista de los valores ⭐️ +valores = persona.values() +print(valores) +# R: dict_values(['taicoding', 27]) + +# ⭐️ Actualizar el valor de una llave ⭐️ +persona["edad"] = 29 +print(persona) +# R: {'nombre': 'taicoding', +# 'edad': 29} +persona.update({"edad": 30}) +print(persona) +# R: {'nombre': 'taicoding', +# 'edad': 30} + +# ⭐️ Eliminar todos los elementos ⭐️ +persona.clear() +print(persona) +# R: {} + +# ⭐️ Crear un diccionario desde una tupla +# de llaves y valores por defecto⭐️ +llaves = ("nombre", "edad") +valor = "vació" +persona = dict.fromkeys(llaves, valor) +print(persona) +# R: {'nombre': 'vació', 'edad': 'vació'} diff --git a/02_estructuras_de_datos/04_tuplas/definicion.py b/02_estructuras_de_datos/04_tuplas/definicion.py new file mode 100644 index 0000000..fb73504 --- /dev/null +++ b/02_estructuras_de_datos/04_tuplas/definicion.py @@ -0,0 +1,14 @@ +""" +@author taicoding +Formas de declarar una Tupla 🐍 +""" +# Sin elementos +coordenada = () +parametro = tuple() +# Con elementos +latitud = tuple((40.015, -3.1243)) +temperatura = (10, "Grados", "Celsius") +vectores = [3, 5, 7], [2, 4, 6] +# Bonus: ✨ Veamos el tipo ✨ +print(type(vectores)) +# R: diff --git a/02_estructuras_de_datos/04_tuplas/metodos.py b/02_estructuras_de_datos/04_tuplas/metodos.py new file mode 100644 index 0000000..fa08d70 --- /dev/null +++ b/02_estructuras_de_datos/04_tuplas/metodos.py @@ -0,0 +1,25 @@ +""" +@author taicoding +Métodos de Tuplas 🐍🧮 +""" + +# Definimos una tupla de calificaciones +calificaciones = (51, 70, 80, 51, 65) +# 🔢 Contar las apariciones de un elemento +# Método: count(elemento) +contador = calificaciones.count(51) +print(contador) +# 🖨️ Resultado: 2 + +# 🔍 Obtener el indice de un elemento +# Método: index(elemento) +indice = calificaciones.index(70) +print(indice) +# 🖨️ Resultado: 1 + +# 📍 Obtener el indice de un elemento +# en un intervalo específico 🔛 +# Método: index(elemento, inicio, fin) +indice = calificaciones.index(51, 2, 5) +print(indice) +# 🖨️ Resultado: 3 diff --git a/02_estructuras_de_datos/04_tuplas/mini_test.py b/02_estructuras_de_datos/04_tuplas/mini_test.py new file mode 100644 index 0000000..c32fa2e --- /dev/null +++ b/02_estructuras_de_datos/04_tuplas/mini_test.py @@ -0,0 +1,9 @@ +""" +@author taicoding +Tema: Tuplas 🐍🧮 +¿Cuál es el resultado? 👩🏻‍🏫👩🏻‍💻🐍 +""" + +menu = ("🧁", "🍪", "🍟", "🍕", "🍨") +helado = menu.index("🍨") +print(helado) diff --git a/03_sentencias_condicionales/definicion.py b/03_sentencias_condicionales/definicion.py new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/03_sentencias_condicionales/definicion.py @@ -0,0 +1 @@ + diff --git a/04_estructuras_de_iteracion/01_while/definicion.py b/04_estructuras_de_iteracion/01_while/definicion.py new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/04_estructuras_de_iteracion/01_while/definicion.py @@ -0,0 +1 @@ + diff --git a/04_estructuras_de_iteracion/02_for/definicion.py b/04_estructuras_de_iteracion/02_for/definicion.py new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/04_estructuras_de_iteracion/02_for/definicion.py @@ -0,0 +1 @@ + diff --git a/05_funciones/definicion.py b/05_funciones/definicion.py new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/05_funciones/definicion.py @@ -0,0 +1 @@ + diff --git a/06_clases/definicion.py b/06_clases/definicion.py new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/06_clases/definicion.py @@ -0,0 +1 @@ + diff --git a/Cadenas/FuncionSplit.py b/Cadenas/FuncionSplit.py new file mode 100644 index 0000000..8093499 --- /dev/null +++ b/Cadenas/FuncionSplit.py @@ -0,0 +1,18 @@ +""" +@author taicoding +Funciones con cadenas parte IV +Función split() +""" +# Definimos una cadena +cadena = "soy uwu cadena" +print(cadena) +# Resultado: soy uwu cadena +""" +Vamos a convertir esta cadena en +cadenas más pequeñas usando la +función split() que por defecto divide +la cadena en cada espacio en blanco +""" +cadenas = cadena.split(" ") +print(cadenas) +# Resultado: ['soy', 'uwu', 'cadena'] diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..261eeb9 --- /dev/null +++ b/LICENSE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/Listas/FuncionesCountIndex.py b/Listas/FuncionesCountIndex.py index b92acfb..dc65652 100644 --- a/Listas/FuncionesCountIndex.py +++ b/Listas/FuncionesCountIndex.py @@ -1,42 +1,53 @@ -''' +""" @author taicoding -Funciones de Listas -Veamos funciones utiles para manejar listas -''' +Listas +Dividir una lista en 2 +""" # En 'emociones' vamos a definir una lista -emociones = list(['u_u','uwu','o_o','uwu']) +emociones = list( + [ + "u_u", + "uwu", + "u.u", + "o_o", + "owo", + "o.o", + ] +) print(emociones) -# Resultado: ['u_u', 'uwu', 'o_o', 'uwu'] -# Con la funcion 'count()' vamos a contar el numero +# Resultado: ['u_u', 'uwu', 'u.u', 'o_o', 'owo', 'o.o'] +# Es muy facil divir una lista +# Primero encontramos + +# Con la funcion 'count()' vamos a contar el numero # de veces que 'uwu' aparece en la lista 'emociones' -nro_uwus = emociones.count('uwu') +nro_uwus = emociones.count("uwu") print(nro_uwus) # Resultado: 2 -# Con la funcion 'index()' vamos a obtener la posicion +# Con la funcion 'index()' vamos a obtener la posicion # de 'uwu' en la lista 'emociones' -posicion_uwu = emociones.index('uwu') +posicion_uwu = emociones.index("uwu") print(posicion_uwu) # Resultado: 1 -#🛑 Si te diste cuenta tenemos 2 'uwu' en la lista 🛑 -# Si los elementos de una lista se repiten la funcion -# 'index()' solo nos devolvera la posicion de la +# 🛑 Si te diste cuenta tenemos 2 'uwu' en la lista 🛑 +# Si los elementos de una lista se repiten la funcion +# 'index()' solo nos devolvera la posicion de la # primera aparicion del elemento 👩🏻‍🏫👩🏻‍💻 - -''' +""" @author taicoding Funciones de Listas Veamos funciones utiles para manejar listas -''' +""" # Vamos a definir la listas 'awa' -awa = ['awa','de','uwu'] -# En la lista 'emociones' vamos a copiar la lista +awa = ["awa", "de", "uwu"] +# En la lista 'emociones' vamos a copiar la lista # 'awa' usando el operador '=' emociones = awa print(emociones) # Resultado: ['awa', 'de', 'uwu'] -# Vamos a revertir la lista emociones con la funcion +# Vamos a revertir la lista emociones con la funcion # 'reverse()' y veremos que paso con la lista 'awa' emociones.reverse() print(emociones) @@ -44,8 +55,6 @@ print(awa) # Resultado: ['uwu', 'de', 'awa'] # 🛑🙀 Oh no! ambas listas fueron modificadas -# Cuando usamos el operador '=' las lista -# involucradas se convierten en un espejo de +# Cuando usamos el operador '=' las lista +# involucradas se convierten en un espejo de # la otra 👩🏻‍🏫👩🏻‍💻🛑 - - diff --git a/Listas/Indices.py b/Listas/Indices.py index 285d015..191f94b 100644 --- a/Listas/Indices.py +++ b/Listas/Indices.py @@ -1,12 +1,12 @@ -''' +""" @author taicoding -Listas: Indices -''' +¿Cómo funcionan los índices de las listas? 🐍 +""" # Definamos la lista 'python' -python = ['P','Y','T','H','O','N'] -# Los indices de los elementos de la lista -# 'python' se pueden leer de las siguientes formas -''' +python = ["P", "Y", "T", "H", "O", "N"] +# Los indices de los elementos de la lista +# 'python' se pueden leer de las siguientes formas +""" +---+---+---+---+---+---+ | P | Y | T | H | O | N | +---+---+---+---+---+---+ indices @@ -14,10 +14,19 @@ +---+---+---+---+---+---+ indices |-6 |-5 |-4 |-3 |-2 |-1 | <<-- derecha a izquierda +---+---+---+---+---+---+ -''' +""" # Mostremos el primer elemento de la lista 'python' # usando ambos tipos de indices 😎👩🏻‍🏫👩🏻‍💻 print(python[0]) # Resultado: P print(python[-6]) -# Resultado: P \ No newline at end of file +# Resultado: P + +""" +@author taicoding +""" +from datetime import date + +if str(date.today()) == "2022-09-13": + print("¡Feliz día del programador!") + print("¡Feliz día de la programadora!") diff --git a/Listas/Segmentacion_III.py b/Listas/Segmentacion_III.py new file mode 100644 index 0000000..44ed1cf --- /dev/null +++ b/Listas/Segmentacion_III.py @@ -0,0 +1,22 @@ +""" +@author taicoding +Listas: Segmentacion III +""" +# En 'emociones' vamos a definir una lista +emociones = list(["u_u", "uwu", "o_o", "uwu"]) +print(emociones) +# Resultado: ['u_u', 'uwu', 'o_o', 'uwu'] +# Ahora vamos a dividir esta lista en dos +# Encontramos la cantidad de elementos de la lista +longitud = len(emociones) +# Con una division entera encontramos la mitad de la +# 'longitud' +medio = longitud // 2 +# Utilizando la sergmentacion delimitamos +# las dos mitades de nuesta lista +una_mitad = emociones[:medio] +otra_mitad = emociones[medio:] +print(una_mitad) +# Resultado: ['u_u', 'uwu'] +print(otra_mitad) +# Resultado: ['o_o', 'uwu'] diff --git a/OperacionesNumericas/OperacionesSimples_I.py b/OperacionesNumericas/OperacionesSimples_I.py deleted file mode 100644 index efcb0df..0000000 --- a/OperacionesNumericas/OperacionesSimples_I.py +++ /dev/null @@ -1,18 +0,0 @@ -''' -@author taicoding -Operadores aritmeticos Parte I -''' -#Definimos las variables con las que realizaremos -#las operaciones aritmeticas -a = 8 -b = 3 -#La adiccion o suma se realiza con -#el operador '+' -suma = a + b -print(suma) -#Resultado: 11 -#La sustraccion o resta se realiza con -#el operador '-' -resta = a - b -print(resta) -#Resultado: 5 diff --git a/QuickQuiz/QuizListas.py b/QuickQuiz/QuizListas.py index c81c150..7a67ed0 100644 --- a/QuickQuiz/QuizListas.py +++ b/QuickQuiz/QuizListas.py @@ -1,63 +1,49 @@ -''' +""" @author taicoding Quick Quiz de Listas -''' -python = [1,2,3,4,5,6] +""" +python = [1, 2, 3, 4, 5, 6] print(python[2:5]) -''' +""" @author taicoding Quick Quiz de Listas -''' -python = [1,2,3,4,5,6] +""" +python = [1, 2, 3, 4, 5, 6] print(python[-3:-1]) -''' +""" @author taicoding Quick Quiz de Listas -''' -postre = ['P','I','E'] +""" +postre = ["P", "I", "E"] print(postre[0:1]) -''' +""" @author taicoding Quick Quiz -''' -cadena = '¡Hola mundo!' +""" +cadena = "¡Hola mundo!" print(len(cadena)) -''' +""" @author taicoding Quick Quiz -''' -cadena = '¡Hola' -sub_cadena ='Hola' +""" +cadena = "¡Hola" +sub_cadena = "Hola" if sub_cadena in cadena: - print('¡Hola mundo!') + print("¡Hola mundo!") else: - print('Bye') + print("Bye") -''' +""" @author taicoding Quick Quiz -''' +""" num = 12 if num % 2 == 0: - print('par') + print("par") else: - print('impar') - - - - - - - - - - - - - - + print("impar") diff --git a/README.md b/README.md index dd9ce12..fb50900 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,28 @@ -# PythonTips -Este repositorio pertenece a las imagenes publicadas en la cuenta de Instagram @t.ia543 +# Python Tips by Taicoding +Encuentra todo el contenido de este repositorio en mi cuenta de Instagram [@taicoding](https://www.instagram.com/taicoding/) + +### ¿Te cuesta entender código en Python? +En este repositorio encontrarás una serie de tips y ejemplos de fragmentos de código en Python comentados linea por linea para que puedas aprender de manera sencilla y rápida. + +### ¿Como usar este repositorio? +1. Clona este repositorio en tu máquina local. +2. Abre el archivo README.md y selecciona el tema que desees aprender. +3. Dentro de los archivos `definicion.py` encontraras la definición correspondiente al tema seleccionado. +4. Dentro de los archivos `mini_test.py` encontraras preguntas y ejemplos de código para que puedas practicar. + +### Temas disponibles +1. [Tipos de datos](/01_tipos_de_datos/) + 1. [Booleanos](/01_tipos_de_datos/01_booleanos/) + 2. [Números](/01_tipos_de_datos/02_numeros/) + 3. [Cadenas](/01_tipos_de_datos/03_cadenas/) +2. [Estructuras de Datos](/02_estructuras_de_datos/) + 1. [Listas](/02_estructuras_de_datos/01_listas/) + 2. [Conjuntos](/02_estructuras_de_datos/02_conjuntos/) + 3. [Diccionarios](/02_estructuras_de_datos/03_diccionarios/) + 4. [Tuplas](/02_estructuras_de_datos/04_tuplas/) +3. [Sentencias Condicionales](/03_sentencias_condicionales/) +4. [Bucles](/04_estructuras_de_iteracion/) + 1. [While](/04_estructuras_de_iteracion/01_while/) + 2. [For](/04_estructuras_de_iteracion/02_for/) +5. [Funciones](/05_funciones/) + diff --git a/TiposDeVariable/Diccionarios.py b/TiposDeVariable/Diccionarios.py index d74ccb3..fd26b8c 100644 --- a/TiposDeVariable/Diccionarios.py +++ b/TiposDeVariable/Diccionarios.py @@ -1,22 +1,23 @@ -''' +""" @author taicoding Tipos de Variables: Diccionarios Los diccionarios son estructuras de datos y un tipo de dato que nos permite almacenar cualquier tipo de dato -''' -# Para definir los elementos de un diccionario utilizamos +""" +# Para definir los elementos de un diccionario utilizamos # el formato 'llave:valor' donde cada 'llave' es unica -instagram = {'nombre':'taicoding','edad':'27' - ,'progreso':0.5 - , 'seguidores':['uwu' - ,'sin' - ,'ewe']} +instagram = { + "nombre": "taicoding", + "edad": "27", + "progreso": 0.5, + "seguidores": ["uwu", "sin", "ewe"], +} print(type(instagram)) # Resultado: # Vamos a acceder al valor de la llave 'nombre' # de nuestro diccionario -print(instagram['nombre']) +print(instagram["nombre"]) # Resultado: taicoding # Ahora vamos a acceder al valor de la llave 'seguidores' -print(instagram['seguidores']) -# Resultado: ['uwu', 'sin', 'ewe'] \ No newline at end of file +print(instagram["seguidores"]) +# Resultado: ['uwu', 'sin', 'ewe'] diff --git a/TiposDeVariable/Type.py b/TiposDeVariable/Type.py index 367909a..ed73210 100644 --- a/TiposDeVariable/Type.py +++ b/TiposDeVariable/Type.py @@ -1,20 +1,18 @@ -''' +""" @author taicoding ¿Para que sirve la funcion type en Python? -''' -#Nos permite ver el tipo de la varible -#que definimos -nombre='Tatiana' +""" +# Nos permite ver el tipo de la varible +# que definimos +nombre = "Tatiana" print(type(nombre)) -#Resultado: -edad=27 +# Resultado: +edad = 27 print(type(edad)) -#Resultado: -estatura=1.65 +# Resultado: +estatura = 1.65 print(type(estatura)) -#Resultado: -casada=False +# Resultado: +casada = False print(type(casada)) -#Resultado: - - +# Resultado: diff --git a/TiposDeVariable/Variables.py b/TiposDeVariable/Variables.py index 2183b94..4153db3 100644 --- a/TiposDeVariable/Variables.py +++ b/TiposDeVariable/Variables.py @@ -1,21 +1,20 @@ -''' +""" @author taicoding ¿Como definir variables en Python? -''' -''' +""" +""" Para definir variable solo necesitamos el nombre de la varible y asignar un valor -''' -#El valor pude ser una cadena -nombre='Tatiana' -#El valor puede ser un caracter -tipoSangre='A' -#El valor puede ser un numero entero -edad=27 -#El valor puede ser un numero -#con punto flotante -estatura=1.65 -#El valor puede ser booleano -casada=False - +""" +# El valor pude ser una cadena +nombre = "Tatiana" +# El valor puede ser un caracter +tipoSangre = "A" +# El valor puede ser un numero entero +edad = 27 +# El valor puede ser un numero +# con punto flotante +estatura = 1.65 +# El valor puede ser booleano +casada = False diff --git a/solution.py b/solution.py new file mode 100644 index 0000000..b7b7963 --- /dev/null +++ b/solution.py @@ -0,0 +1,2 @@ +paises = [{"pais": "Bolivia", "capital": "Sucre"}, {"pais": "Peru", "capital": "Lima"}] +print(paises)