Commit ce58c217 authored by alan's avatar alan

01

parent 205c898a
......@@ -19,7 +19,7 @@
"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",
"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",
......@@ -774,10 +774,34 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 22,
"metadata": {},
"outputs": [],
"source": []
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"2\n",
"4\n",
"6\n",
"8\n",
"10\n",
"12\n",
"14\n",
"16\n",
"18\n",
"20\n"
]
}
],
"source": [
"i = 0\n",
"while i < 20:\n",
" i+=2\n",
" print(i)\n",
" \n",
" "
]
},
{
"cell_type": "markdown",
......@@ -788,12 +812,28 @@
},
{
"cell_type": "code",
"execution_count": 28,
"execution_count": 80,
"metadata": {},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"13\n",
"21\n",
"34\n",
"55\n",
"89\n"
]
}
],
"source": [
"A = [1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89]\n",
"\n"
"A = [1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89] \n",
"for x in A:\n",
" if(x > 10): \n",
" print (x)\n",
" \n",
" "
]
},
{
......@@ -805,12 +845,25 @@
},
{
"cell_type": "code",
"execution_count": 29,
"execution_count": 125,
"metadata": {},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"{1, 2, 3, 5, 8, 13}\n"
]
}
],
"source": [
"a = [1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89]\n",
"b = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]\n"
"a = set ([1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89])\n",
"b = set ([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13])\n",
"c = a&b \n",
"print(c)\n",
"\n",
"\n",
" \n"
]
},
{
......@@ -822,12 +875,47 @@
},
{
"cell_type": "code",
"execution_count": 30,
"execution_count": 160,
"metadata": {},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Cuantos numeros de Fibonacci desea:\n",
"10\n",
"[1]\n",
"[1, 1]\n",
"[1, 1, 2]\n",
"[1, 1, 2, 3]\n",
"[1, 1, 2, 3, 5]\n",
"[1, 1, 2, 3, 5, 8]\n",
"[1, 1, 2, 3, 5, 8, 13]\n",
"[1, 1, 2, 3, 5, 8, 13, 21]\n",
"[1, 1, 2, 3, 5, 8, 13, 21, 34]\n",
"[1, 1, 2, 3, 5, 8, 13, 21, 34, 55]\n"
]
}
],
"source": [
"def fibonacci(n):\n",
" pass"
" pass\n",
"a = 0\n",
"b = 1\n",
"fib = []\n",
"\n",
"print (\"Cuantos numeros de Fibonacci desea:\")\n",
"n = int (input())\n",
"\n",
"i = 0\n",
"while i < n:\n",
" fib.append(b)\n",
" c = a+b\n",
" a = b\n",
" b = c\n",
" i +=1\n",
" print (fib)\n",
" "
]
},
{
......@@ -839,11 +927,28 @@
},
{
"cell_type": "code",
"execution_count": 31,
"execution_count": 110,
"metadata": {},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"20\n"
]
}
],
"source": [
"a = [8, 2, 3, 0, 7]"
"a = [8, 2, 3, 0, 7]\n",
"def suma(a):\n",
" cuenta = 0\n",
" for i in a:\n",
" cuenta = cuenta +i\n",
" return cuenta\n",
"\n",
"print( suma (a))\n",
"\n",
" "
]
},
{
......@@ -855,18 +960,32 @@
},
{
"cell_type": "code",
"execution_count": 32,
"metadata": {},
"outputs": [],
"execution_count": 117,
"metadata": {
"scrolled": true
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"{1, 2, 3, 4, 5}\n"
]
}
],
"source": [
"a = [1,2,2,3,3,3,3,4,5,5]"
"a = [1,2,2,3,3,3,3,4,5,5]\n",
"b = set(a)\n",
"print (b)\n",
"\n",
"\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### 1.5.7 Escribe una funcion que indique si un numero es o no perfecto.\n",
"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"
......@@ -874,22 +993,40 @@
},
{
"cell_type": "code",
"execution_count": 34,
"execution_count": 26,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Escribe un nuemero:8\n"
"Numero a comprobar:99999999\n",
"El 99999999 , NO es perfecto \n"
]
}
],
"source": [
"def perfect(x):\n",
" pass\n",
"numero = input(\"Escribe un nuemero:\")\n",
"perfect(numero)"
"def NP(x):\n",
" suma = 0\n",
" for i in range(1,x):\n",
" if (x % i == 0):\n",
" suma += i\n",
" \n",
" if x == suma:\n",
"\n",
" return True\n",
"\n",
" else:\n",
"\n",
" return False\n",
"\n",
"x = int(input(\"Numero a comprobar:\"))\n",
"\n",
"if NP(x):\n",
" print(\"El %s es perfecto\" % x)\n",
"else:\n",
" \n",
" print(\"El %s , NO es perfecto \" % x)"
]
},
{
......@@ -904,14 +1041,46 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 45,
"metadata": {},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"ingrese el valor de n:3\n",
"1\n",
"\n",
"\n",
"1\n",
"1.0\n",
"\n",
"\n",
"1\n",
"2.0\n",
"1.0\n",
"\n",
"\n",
"1\n",
"3.0\n",
"3.0\n",
"1.0\n",
"\n",
"\n"
]
}
],
"source": [
"def pascal(n):\n",
" pass\n",
"numero = input(\"Indica el numero de filas:\")\n",
"pascal(numero)"
"n = int( input(\"ingrese el valor de n:\"))\n",
"\n",
"for i in range (0, n+1):\n",
" n = 1\n",
"\n",
" for j in range(0, i+1):\n",
" print( str(n) + \"\")\n",
" n = n * ( i - j ) / (j + 1)\n",
"\n",
" print(\"\\n\")"
]
},
{
......@@ -919,9 +1088,19 @@
"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. "
"[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. \n",
" \n",
" \n",
" \n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "markdown",
"metadata": {},
......@@ -970,7 +1149,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.5.3"
"version": "3.5.2"
}
},
"nbformat": 4,
......
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