Commit 1db62977 authored by Gaspar's avatar Gaspar

tarea1 finalizadda

parent efa8d9df
...@@ -877,12 +877,40 @@ ...@@ -877,12 +877,40 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 30, "execution_count": 19,
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"cuantos numeros de la secuancia Fibonacci quiere calcular:10\n",
"0\n",
"1\n",
"1\n",
"2\n",
"3\n",
"5\n",
"8\n",
"13\n",
"21\n",
"34\n",
"55\n"
]
}
],
"source": [ "source": [
"def fibonacci(n):\n", "def fibonacci(n):\n",
" pass" " if n == 0: \n",
" return 0\n",
" elif n == 1:\n",
" return 1\n",
" else: \n",
" return fibonacci(n-1)+fibonacci(n-2)\n",
"\n",
"numero = int(input(\"cuantos numeros de la secuancia Fibonacci quiere calcular:\"))\n",
"for i in range(numero+1):\n",
" print(fibonacci(i))"
] ]
}, },
{ {
...@@ -923,7 +951,7 @@ ...@@ -923,7 +951,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 21, "execution_count": 2,
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
{ {
...@@ -936,7 +964,10 @@ ...@@ -936,7 +964,10 @@
], ],
"source": [ "source": [
"a = [1,2,2,3,3,3,3,4,5,5]\n", "a = [1,2,2,3,3,3,3,4,5,5]\n",
"print(list(set(a)))" "def printUnique(a):\n",
" print(list(set(a)))\n",
" \n",
"printUnique(a)"
] ]
}, },
{ {
...@@ -951,21 +982,31 @@ ...@@ -951,21 +982,31 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 34, "execution_count": 13,
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
{ {
"name": "stdout", "name": "stdout",
"output_type": "stream", "output_type": "stream",
"text": [ "text": [
"Escribe un nuemero:8\n" "Escribe un nuemero:10000\n",
"10000 no es un numero perfecto\n"
] ]
} }
], ],
"source": [ "source": [
"def perfect(x):\n", "def perfect(x):\n",
" pass\n", " suma = 0\n",
"numero = input(\"Escribe un nuemero:\")\n", " for i in range(1,x):\n",
" if x % i == 0:\n",
" suma += i\n",
" \n",
" if x == suma:\n",
" print(\"%s es un numero perfecto\" % x)\n",
" else:\n",
" print(\"%s no es un numero perfecto\" % x)\n",
" \n",
"numero = int(input(\"Escribe un nuemero:\"))\n",
"perfect(numero)" "perfect(numero)"
] ]
}, },
...@@ -981,13 +1022,36 @@ ...@@ -981,13 +1022,36 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": null, "execution_count": 40,
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Indica el numero de filas:5\n",
"[1]\n",
"[1, 1]\n",
"[1, 2, 1]\n",
"[1, 3, 3, 1]\n",
"[1, 4, 6, 4, 1]\n",
"[1, 5, 10, 10, 5, 1]\n"
]
}
],
"source": [ "source": [
"def pascal(n):\n", "def pascal(n):\n",
" pass\n", " lista = [[1],[1,1]]\n",
"numero = input(\"Indica el numero de filas:\")\n", " print([1])\n",
" print([1,1])\n",
" for i in range(1, n):\n",
" linea = [1]\n",
" for j in range(0,len(lista[i])-1):\n",
" linea.extend([ lista[i][j] + lista[i][j+1] ])\n",
" linea.append(1)\n",
" lista.append(linea)\n",
" print(linea)\n",
"numero = int(input(\"Indica el numero de filas:\"))\n",
"pascal(numero)" "pascal(numero)"
] ]
}, },
...@@ -999,6 +1063,30 @@ ...@@ -999,6 +1063,30 @@
"[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. " "[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": 32,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"False\n",
"False\n",
"True\n"
]
}
],
"source": [
"def panagrama(phrase):\n",
" alphabet = \"abcdefghijklmnopqrstuvwxyz\"\n",
" return not (set(alphabet) - set(phrase))\n",
"print(panagrama(\"zbcdefghijkl onpqrstuvwxya\"))\n",
"print(panagrama(\"abcdefghijkl onpqrstuvwxyz\"))\n",
"print(panagrama(\"abcdefghijklmnopqrstuvwxyz\"))"
]
},
{ {
"cell_type": "markdown", "cell_type": "markdown",
"metadata": {}, "metadata": {},
...@@ -1023,6 +1111,35 @@ ...@@ -1023,6 +1111,35 @@
"999999999" "999999999"
] ]
}, },
{
"cell_type": "code",
"execution_count": 23,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"1\n",
"22\n",
"333\n",
"4444\n",
"55555\n",
"666666\n",
"7777777\n",
"88888888\n",
"999999999\n"
]
}
],
"source": [
"for i in range(1, 10):\n",
" aux = \"\"\n",
" for j in range(1, i + 1):\n",
" aux += str(i)\n",
" print(aux);"
]
},
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": null, "execution_count": null,
......
...@@ -877,12 +877,40 @@ ...@@ -877,12 +877,40 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 30, "execution_count": 19,
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"cuantos numeros de la secuancia Fibonacci quiere calcular:10\n",
"0\n",
"1\n",
"1\n",
"2\n",
"3\n",
"5\n",
"8\n",
"13\n",
"21\n",
"34\n",
"55\n"
]
}
],
"source": [ "source": [
"def fibonacci(n):\n", "def fibonacci(n):\n",
" pass" " if n == 0: \n",
" return 0\n",
" elif n == 1:\n",
" return 1\n",
" else: \n",
" return fibonacci(n-1)+fibonacci(n-2)\n",
"\n",
"numero = int(input(\"cuantos numeros de la secuancia Fibonacci quiere calcular:\"))\n",
"for i in range(numero+1):\n",
" print(fibonacci(i))"
] ]
}, },
{ {
...@@ -923,7 +951,7 @@ ...@@ -923,7 +951,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 21, "execution_count": 2,
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
{ {
...@@ -936,7 +964,10 @@ ...@@ -936,7 +964,10 @@
], ],
"source": [ "source": [
"a = [1,2,2,3,3,3,3,4,5,5]\n", "a = [1,2,2,3,3,3,3,4,5,5]\n",
"print(list(set(a)))" "def printUnique(a):\n",
" print(list(set(a)))\n",
" \n",
"printUnique(a)"
] ]
}, },
{ {
...@@ -951,21 +982,31 @@ ...@@ -951,21 +982,31 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 34, "execution_count": 13,
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
{ {
"name": "stdout", "name": "stdout",
"output_type": "stream", "output_type": "stream",
"text": [ "text": [
"Escribe un nuemero:8\n" "Escribe un nuemero:10000\n",
"10000 no es un numero perfecto\n"
] ]
} }
], ],
"source": [ "source": [
"def perfect(x):\n", "def perfect(x):\n",
" pass\n", " suma = 0\n",
"numero = input(\"Escribe un nuemero:\")\n", " for i in range(1,x):\n",
" if x % i == 0:\n",
" suma += i\n",
" \n",
" if x == suma:\n",
" print(\"%s es un numero perfecto\" % x)\n",
" else:\n",
" print(\"%s no es un numero perfecto\" % x)\n",
" \n",
"numero = int(input(\"Escribe un nuemero:\"))\n",
"perfect(numero)" "perfect(numero)"
] ]
}, },
...@@ -981,13 +1022,36 @@ ...@@ -981,13 +1022,36 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": null, "execution_count": 40,
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Indica el numero de filas:5\n",
"[1]\n",
"[1, 1]\n",
"[1, 2, 1]\n",
"[1, 3, 3, 1]\n",
"[1, 4, 6, 4, 1]\n",
"[1, 5, 10, 10, 5, 1]\n"
]
}
],
"source": [ "source": [
"def pascal(n):\n", "def pascal(n):\n",
" pass\n", " lista = [[1],[1,1]]\n",
"numero = input(\"Indica el numero de filas:\")\n", " print([1])\n",
" print([1,1])\n",
" for i in range(1, n):\n",
" linea = [1]\n",
" for j in range(0,len(lista[i])-1):\n",
" linea.extend([ lista[i][j] + lista[i][j+1] ])\n",
" linea.append(1)\n",
" lista.append(linea)\n",
" print(linea)\n",
"numero = int(input(\"Indica el numero de filas:\"))\n",
"pascal(numero)" "pascal(numero)"
] ]
}, },
...@@ -999,6 +1063,30 @@ ...@@ -999,6 +1063,30 @@
"[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. " "[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": 32,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"False\n",
"False\n",
"True\n"
]
}
],
"source": [
"def panagrama(phrase):\n",
" alphabet = \"abcdefghijklmnopqrstuvwxyz\"\n",
" return not (set(alphabet) - set(phrase))\n",
"print(panagrama(\"zbcdefghijkl onpqrstuvwxya\"))\n",
"print(panagrama(\"abcdefghijkl onpqrstuvwxyz\"))\n",
"print(panagrama(\"abcdefghijklmnopqrstuvwxyz\"))"
]
},
{ {
"cell_type": "markdown", "cell_type": "markdown",
"metadata": {}, "metadata": {},
...@@ -1023,6 +1111,35 @@ ...@@ -1023,6 +1111,35 @@
"999999999" "999999999"
] ]
}, },
{
"cell_type": "code",
"execution_count": 23,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"1\n",
"22\n",
"333\n",
"4444\n",
"55555\n",
"666666\n",
"7777777\n",
"88888888\n",
"999999999\n"
]
}
],
"source": [
"for i in range(1, 10):\n",
" aux = \"\"\n",
" for j in range(1, i + 1):\n",
" aux += str(i)\n",
" print(aux);"
]
},
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": null, "execution_count": null,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment