"n = int(input(\"Numero de lineas para triangulo de Pascal: \"))\n",
"trianguloPascal(n)"
]
},
{
...
...
@@ -922,6 +1064,34 @@
"[Wikipedia](https://es.wikipedia.org/wiki/Pangrama):Un pangrama (del griego: παν γραμμα, «todas las letras») o frase holoalfabética es un texto que usa todas las letras posibles del alfabeto de un idioma. "
]
},
{
"cell_type": "code",
"execution_count": 14,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Escribe una frase: The quick brown fox jumps over the lazy dog\n",
"Las comprensiones de python proveen de una forma consisa de crear listas, diccionarios y conjuntos. Su nombre proviene de teria de conjuntos en donde la *notación contructiva de conjuntos* o comprensión se define como:\n",
"\n",
"\n",
"[Wikipedia](https://en.wikipedia.org/wiki/Set-builder_notation): Definir conjuntos por propiedades también se conoce como ***comprensión de conjuntos***, abstracción de conjuntos o como definición de la intención de un conjunto.\n",
"\n",
"En python la estructura de una comprensión es la siguiente:![img](https://python-3-patterns-idioms-test.readthedocs.io/en/latest/_images/listComprehensions.gif)"
]
},
{
"cell_type": "code",
"execution_count": 253,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"[2, 2, 4, 6, 8]"
]
},
"execution_count": 253,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"old_list = [1,2,2,3,4,5,6,7,7,8,9]\n",
"new_list = []\n",
"for i in old_list:\n",
" if i%2==0:\n",
" new_list.append(i)\n",
"new_list"
]
},
{
"cell_type": "code",
"execution_count": 256,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"[2, 2, 4, 6, 8]"
]
},
"execution_count": 256,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# Lista\n",
"new_list=[i for i in old_list if i%2==0]\n",
"new_list"
]
},
{
"cell_type": "code",
"execution_count": 188,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"{0: 1,\n",
" 1: 1,\n",
" 2: 4,\n",
" 3: 27,\n",
" 4: 256,\n",
" 5: 3125,\n",
" 6: 46656,\n",
" 7: 823543,\n",
" 8: 16777216,\n",
" 9: 387420489}"
]
},
"execution_count": 188,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# Diccionario\n",
"{ i:i**i for i in range(10)}"
]
},
{
"cell_type": "code",
"execution_count": 348,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"[[1, 0, 0], [0, 1, 0], [0, 0, 1]]"
]
},
"execution_count": 348,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# Comprensión anidada\n",
"k = [ [ 1 if item_idx == row_idx else 0 for item_idx in range(0, 3) ] for row_idx in range(0, 3) ]\n",
"k"
]
},
{
"cell_type": "code",
"execution_count": 34,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"{1, 2, 3, 4, 5, 6, 7, 8, 9}"
]
},
"execution_count": 34,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# Conjunto\n",
"new_set={i for i in old_list}\n",
"new_set"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## 2.2 Expresiones lambda $\\lambda$\n",
"Una función anónima o **expresión lambda** es una subrutina definida que no está enlazada a un identificador. Las funciones lambda generalmente son Argumentos que son pasados a otras funciónes de orden superior o Usadas para construir el resultado de una función de orden superior que necesita retornar una función [[Wikiedia](https://en.wikipedia.org/wiki/Anonymous_function)].\n",
"\n",
"En Python las expresiones lambda no pueden utilizar ciclos ni utilizar la plabra reservada **return**, su sintaxis es:```lambda <parametros>:<expresion>```\n",
"\n",
"*Nota: **filter** regresa una lista de elementos para los cuales una funcion regresa **True**; **map** aplica una funcion a todos los ementos de una lista.*\n",
"Los Generadores son funciones o expresiones que regesan un valor iterador en lugar de un valor, las para que una funcion regrese un generador en lugar de un valor se utiliza la palabra reservada **yield** en lugar de **return**."
"doctest prueba el código fuente ejecutando ejemplos incrustados en la documentación y verificando que producen los resultados esperados. Funciona al analizar el texto de ayuda para encontrar ejemplos, ejecutarlos y luego comparar el texto de salida con el valor esperado.\n"
]
},
{
"cell_type": "code",
"execution_count": 10,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Trying:\n",
" multiply(4, 3)\n",
"Expecting:\n",
" 12\n",
"ok\n",
"Trying:\n",
" multiply('a', 3)\n",
"Expecting:\n",
" 'aaa'\n",
"ok\n",
"1 items had no tests:\n",
" __main__\n",
"1 items passed all tests:\n",
" 2 tests in __main__.multiply\n",
"2 tests in 2 items.\n",
"2 passed and 0 failed.\n",
"Test passed.\n"
]
},
{
"data": {
"text/plain": [
"TestResults(failed=0, attempted=2)"
]
},
"execution_count": 10,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"def multiply(a, b):\n",
" '''\n",
" >>> multiply(4, 3)\n",
" 12\n",
" >>> multiply('a', 3)\n",
" 'aaa'\n",
" '''\n",
" return a * b\n",
"import doctest\n",
"\n",
"doctest.testmod(verbose=True)\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## 1.4 Documentacion y Casos de Prueba"
"## 2.8 Ejercicios\n",
"Escribe la documentacion y los casos de prueba para todos los ejercicios de la semana 1 y 2."
"<h1><center>Tópicos Avanzados de Programación</center></h1>\n",
"\n",
"# 1. Python \n",
"## 1.1 Introduccion"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Python fue creado en 1991 por Guido van Rossum, con la filosofia de crear codigo legible, por lo que la identacion es obligatoria. Su desarrollo esta administrado por **Python Software Foundation** (python.org).\n",
"\n",
"\n",
"Caracteristicas:\n",
"* Alto Nivel\n",
"* Interpretado (Se ejecuta sin compilación previa)\n",
"* Tipificación Dinamica (Se realiza durante en tiempo de ejecución)\n",
"* Multiparadigma\n",
"* Interactivo (con ipython)\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## 1.2 Tipos de Datos\n",
"#### Numericos\n",
"* int\n",
"* float\n",
"* complex"
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"int"
]
},
"execution_count": 1,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"type (1)"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"float"
]
},
"execution_count": 2,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"type (1.)"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"complex"
]
},
"execution_count": 3,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"type ((1+2j))"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Secuencias\n",
"* list\n",
"* tuple \n",
"* range\n"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"list"
]
},
"execution_count": 4,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"type([1,2,3])"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"tuple"
]
},
"execution_count": 5,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"type((1,2))"
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"range"
]
},
"execution_count": 6,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"type(range(1))"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Texto\n",
"* str\n"
]
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"str"
]
},
"execution_count": 7,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"type(\"Hola\")"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Mapeo\n",
"* dict"
]
},
{
"cell_type": "code",
"execution_count": 8,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"dict"
]
},
"execution_count": 8,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"type({\"mensaje\":\"hola mundo\"})"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Conjuntos\n",
"* set\n",
"* frozenset"
]
},
{
"cell_type": "code",
"execution_count": 9,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"{1, 2, 3, 5, 6}"
]
},
"execution_count": 9,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"set([1,2,3,1,5,2,6])\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## 1.2 Operadores\n",
"### Comparación \n",
"| Simbolo | Operador |\n",
"|---------|----------|\n",
"| < | menor que |\n",
"| <= | Menor o igual que |\n",
"| >\t| Mayor que |Mayor o igual que | \n",
"| == | Igual |\n",
"| != | Desigual |\n",
"| is | Identidad de Objetos |\n",
"| is not | Identidad Negada de Objetos|\n",
"\n"
]
},
{
"cell_type": "code",
"execution_count": 10,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"True"
]
},
"execution_count": 10,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"6 < 9"
]
},
{
"cell_type": "code",
"execution_count": 11,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"False"
]
},
"execution_count": 11,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"6 > 9"
]
},
{
"cell_type": "code",
"execution_count": 12,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"False"
]
},
"execution_count": 12,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"6 == 9"
]
},
{
"cell_type": "code",
"execution_count": 13,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"True"
]
},
"execution_count": 13,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"6 != 9"
]
},
{
"cell_type": "code",
"execution_count": 14,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"False"
]
},
"execution_count": 14,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"6 is float(6)\n"
]
},
{
"cell_type": "code",
"execution_count": 15,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"True"
]
},
"execution_count": 15,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"6 is int(6)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Operaciones\n",
"| Operacion\t| Result |\n",
"|-----------|--------|\n",
"| x + y\t| Suma |\n",
"| x - y\t| Resta |\n",
"| x * y\t| Multiplicacion |\n",
"| x / y\t| Division |\n",
"| x // y | Division (Parte entera) |\n",
"| x % y\t| Modulo|\n",
"| x ** y | x a la potencia y |\n",
"\n",
"### Operador a nivel de bits\n",
"| Operation | Result |\n",
"|-----------|--------|\n",
"| x | y\t| x OR y |\n",
"| x ^ y\t| x XOR y |\n",
"| x & y\t| x AND y |\n",
"| x << n | x desplazado n bits a la izquierda |\n",
"| x >> n | x desplazado n bits a la derecha |\n",
"| ~x | x Negado |\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## 1.3 Control de Flujo\n",
"Las estructuruas de control de flijo permiten modificar el flujo de ejecución de las instrucciones de un programa mediante el valor binario de una condicion. Python cuenta con las siguientes estructuras de control:\n",
"\n",
"* if, elif\n",
"* else\n",
"* for\n",
"* while\n",
"* continue\n",
"* break\n",
"* pass\n",
"* try, exeption\n",
"\n"
]
},
{
"cell_type": "code",
"execution_count": 16,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"True\n"
]
}
],
"source": [
"if True:\n",
" print(\"True\")\n",
"else:\n",
" print(\"False\")"
]
},
{
"cell_type": "code",
"execution_count": 17,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"0\n",
"1\n",
"2\n",
"3\n",
"4\n"
]
}
],
"source": [
"for i in range(5):\n",
" print(i)"
]
},
{
"cell_type": "code",
"execution_count": 18,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Vacio\n"
]
}
],
"source": [
"for i in range(0):\n",
" print(i)\n",
"else:\n",
" print(\"Vacio\")"
]
},
{
"cell_type": "code",
"execution_count": 19,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"1\n",
"2\n",
"3\n",
"4\n",
"5\n"
]
}
],
"source": [
"i = 0\n",
"while i < 5:\n",
" i+=1\n",
" print(i)"
]
},
{
"cell_type": "code",
"execution_count": 20,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"0\n",
"1\n",
"3\n",
"4\n"
]
}
],
"source": [
"for i in range(5):\n",
" if(i==2):\n",
" continue\n",
" print(i)"
]
},
{
"cell_type": "code",
"execution_count": 21,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"0\n",
"1\n"
]
}
],
"source": [
"for i in range(5):\n",
" if(i==2):\n",
" break\n",
" print(i)"
]
},
{
"cell_type": "code",
"execution_count": 22,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"0\n",
"1\n",
"2\n",
"3\n",
"4\n"
]
}
],
"source": [
"for i in range(5):\n",
" if(i==2):\n",
" pass\n",
" print(i)"
]
},
{
"cell_type": "code",
"execution_count": 23,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"0.5\n",
"0.6666666666666666\n",
"1.0\n",
"2.0\n",
"ERROR\n"
]
}
],
"source": [
"for i in reversed(range(5)):\n",
" try:\n",
" print(2/i)\n",
" except:\n",
" print(\"ERROR\")\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Todos los objetos de python son considerados verdaders (True) exepto los siguintes:\n",
"* Constantes definidas como: None o False.\n",
"* Cero de cualquier tipo numerico: 0, 0.0, 0j, Decimal(0), Fraction(0, 1)\n",
"Una función es un conjunto de setencias que pueden ser invocadas varias veces durante la ejecución de un programa. Permiten minimizar el codigo, amuentar su legibilidad y permiten reutilizar código. En python las funciones son definida por la palabra reservada **def**. \n",
"\n"
]
},
{
"cell_type": "code",
"execution_count": 24,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Hello World\n"
]
}
],
"source": [
"def HelloWorld():\n",
" print(\"Hello World\")\n",
"\n",
"HelloWorld()\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### 1.4.1 Parametros\n",
"La funciones pueden aceptar arguentos de entrada y devoler resultados."
]
},
{
"cell_type": "code",
"execution_count": 25,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Hello Mario\n"
]
}
],
"source": [
"def Hello(name):\n",
" print(\"Hello \"+name)\n",
"Hello(\"Mario\")"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### 1.4.2 Parametros Opcionales\n",
"Las funciones tampien pueden aceptar parametros opcionales, los cuales toman en valor indicado por defecto si no son pasados a la funcion."
]
},
{
"cell_type": "code",
"execution_count": 26,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Hello Mario!!!\n",
"Hello Mario?\n",
"Hello Mario!\n",
"Hello Alex!!\n"
]
},
{
"data": {
"text/plain": [
"[1]"
]
},
"execution_count": 26,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"def Hello(name, x=\"!!!\"):\n",
" print(\"Hello \" + name + x)\n",
"Hello(\"Mario\")\n",
"Hello(\"Mario\",\"?\")\n",
"Hello(x=\"!\", name=\"Mario\")\n",
"p = {\"name\":\"Alex\", \"x\":\"!!\"}\n",
"Hello(**p)\n",
"[1,]"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### 1.4.3 Desempaquetado"
]
},
{
"cell_type": "code",
"execution_count": 27,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"0 1 2\n",
"0 4 5\n",
"[6, 7, 8] 1 2\n",
"6 7 8\n",
"{'a': 9, 'b': 10, 'c': 11} 1 2\n",
"9 10 11\n"
]
}
],
"source": [
"def unpack(a,b=1,c=2):\n",
" print(a,b,c)\n",
"\n",
"l = [6,7,8] \n",
"d = {\"a\":9,\"b\":10,\"c\":11} \n",
"unpack(0)\n",
"unpack(0, 4, 5)\n",
"unpack(l)\n",
"unpack(*l)\n",
"unpack(d)\n",
"unpack(**d)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## 1.5 Ejercicios\n",
"### 1.5.1 Imprimir todos los numeros pares entre 0 y 20 usando *for* o *while*."
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"[0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20]"
]
},
"execution_count": 3,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"[i for i in range(0,21,2)]"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### 1.5.2 Imprimir todos los numeros mayores a 10 de la lista A"
]
},
{
"cell_type": "code",
"execution_count": 9,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"[13, 21, 34, 55, 89]"
]
},
"execution_count": 9,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"A = [1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89]\n",
"\n",
"[j for j in A if j > 10]"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### 1.5.3 Dadas dos listas A y B, obten una lista con sus elementos comunes (A∩B)."
"### 1.5.4 Pregunta al usario cuantos numeros de la secuancia Fibonacci quiere calcular y escribe una funcion que calcule la secuencia e imprima el resultado."
"### 1.5.5 Escribe una funcion que sume todos los uneros en una lista."
]
},
{
"cell_type": "code",
"execution_count": 65,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"20"
]
},
"execution_count": 65,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"from functools import reduce\n",
"\n",
"a = [8, 2, 3, 0, 7]\n",
"\n",
"reduce(lambda n, m: n+m, a)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### 1.5.6 Escribe una funcion que tome una lista y regrese los elementos unicos en la lista.\n"
]
},
{
"cell_type": "code",
"execution_count": 41,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"[1, 2, 3, 4, 5]"
]
},
"execution_count": 41,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"b = [1,2,2,3,3,3,3,4,5,5]\n",
"\n",
"list(set(b))"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### 1.5.7 Escribe una funcion que indique si un numero es o no perfecto.\n",
"[Wikipedia:](https://es.wikipedia.org/wiki/N%C3%BAmero_perfecto) *Un número perfecto es un número natural que es igual a la suma de sus divisores propios positivos. Dicho de otra forma, un número perfecto es aquel que es amigo de sí mismo.\n",
"Así, 6 es un número perfecto porque sus divisores propios son 1, 2 y 3; y 6 = 1 + 2 + 3. Los siguientes números perfectos son 28, 496 y 8128.*\n",
"\n"
]
},
{
"cell_type": "code",
"execution_count": 47,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Escribe un numero: 8128\n",
"El número 8128 ES perfecto\n"
]
}
],
"source": [
"def perfect(n):\n",
" fact = [1]\n",
" [fact.append(x) for x in range(2,n) if n % x == 0]\n",
" print('El número', n, 'ES perfecto') if sum(fact) == n else print('El número', n, 'NO es perfecto')\n",
"\n",
"numero = int(input(\"Escribe un numero: \"))\n",
"perfect(numero)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### 1.5.8 Escribe una funcion que imprima las prieras *n* filas del triangulo de Pascal.\n",
"n = int(input(\"Numero de lineas para triangulo de Pascal: \"))\n",
"trianguloPascal(n)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### 1.5.9 Escribe una funcion que indique si una frase es un panagrama.\n",
"[Wikipedia](https://es.wikipedia.org/wiki/Pangrama):Un pangrama (del griego: παν γραμμα, «todas las letras») o frase holoalfabética es un texto que usa todas las letras posibles del alfabeto de un idioma. "
]
},
{
"cell_type": "code",
"execution_count": 64,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Escribe una frase: The quick brown fox jumps over the lazy dog\n",
"La frase ES un Panagrama\n"
]
}
],
"source": [
"def esPanagrama(frase):\n",
" alfabeto = 'abcdefghijklmnopqrstuvwxyz'\n",
" for w in alfabeto:\n",
" if w not in frase:\n",
" print('La frase NO es un Panagrama')\n",
" break\n",
" else:\n",
" print('La frase ES un Panagrama')\n",
" \n",
"texto = input('Escribe una frase: ')\n",
"esPanagrama(texto)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### 1.5.10 Escribe un programa que imprima el siguiente un **for** anidado.\n",
"1\n",
"\n",
"22\n",
"\n",
"333\n",
"\n",
"4444\n",
"\n",
"55555\n",
"\n",
"666666\n",
"\n",
"7777777\n",
"\n",
"88888888\n",
"\n",
"999999999"
]
},
{
"cell_type": "code",
"execution_count": 59,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"1\n",
"\n",
"22\n",
"\n",
"333\n",
"\n",
"4444\n",
"\n",
"55555\n",
"\n",
"666666\n",
"\n",
"7777777\n",
"\n",
"88888888\n",
"\n",
"999999999\n",
"\n"
]
}
],
"source": [
"for z in range(1, 10): print(str(z) * z + '\\n')"