Commit 941b67c4 authored by alan's avatar alan

apuntes clases

parent 42ada44a
......@@ -55,6 +55,7 @@
}
],
"source": [
"a = 1\n",
"type (1)"
]
},
......@@ -75,6 +76,8 @@
}
],
"source": [
"\n",
"\n",
"type (1.)"
]
},
......@@ -224,6 +227,15 @@
"type({\"mensaje\":\"hola mundo\"})"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"d = (\"a\":1, \"b\":2, \"c\":3 )"
]
},
{
"cell_type": "markdown",
"metadata": {},
......@@ -457,7 +469,7 @@
},
{
"cell_type": "code",
"execution_count": 17,
"execution_count": 3,
"metadata": {},
"outputs": [
{
......@@ -467,13 +479,13 @@
"0\n",
"1\n",
"2\n",
"3\n",
"4\n"
"3\n"
]
}
],
"source": [
"for i in range(5):\n",
"i = (\"a\",2,3,0)\n",
"for i in range(4):\n",
" print(i)"
]
},
......@@ -875,7 +887,7 @@
},
{
"cell_type": "code",
"execution_count": 160,
"execution_count": 5,
"metadata": {},
"outputs": [
{
......@@ -883,7 +895,7 @@
"output_type": "stream",
"text": [
"Cuantos numeros de Fibonacci desea:\n",
"10\n",
"15\n",
"[1]\n",
"[1, 1]\n",
"[1, 1, 2]\n",
......@@ -893,13 +905,17 @@
"[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"
"[1, 1, 2, 3, 5, 8, 13, 21, 34, 55]\n",
"[1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89]\n",
"[1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144]\n",
"[1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233]\n",
"[1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377]\n",
"[1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610]\n"
]
}
],
"source": [
"def fibonacci(n):\n",
" pass\n",
"\n",
"a = 0\n",
"b = 1\n",
"fib = []\n",
......@@ -981,6 +997,33 @@
"\n"
]
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {},
"outputs": [
{
"ename": "SyntaxError",
"evalue": "invalid syntax (<ipython-input-7-e6a3d31a7e8b>, line 7)",
"output_type": "error",
"traceback": [
"\u001b[0;36m File \u001b[0;32m\"<ipython-input-7-e6a3d31a7e8b>\"\u001b[0;36m, line \u001b[0;32m7\u001b[0m\n\u001b[0;31m my_set = (set(some:list))\u001b[0m\n\u001b[0m ^\u001b[0m\n\u001b[0;31mSyntaxError\u001b[0m\u001b[0;31m:\u001b[0m invalid syntax\n"
]
}
],
"source": [
"def test_list2set():\n",
" a = [1,2,2,3,3,3,3,4,5,5]\n",
" b =[1,2,3,4,5,]\n",
" print(\"ok\" if list2set(a)==b else \"ko\")\n",
" \n",
"def list2set(some_list):\n",
" my_set = (set(some:list))\n",
" return my_set:\n",
" \n",
"test_list2set()"
]
},
{
"cell_type": "markdown",
"metadata": {},
......@@ -993,15 +1036,15 @@
},
{
"cell_type": "code",
"execution_count": 26,
"execution_count": 2,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Numero a comprobar:99999999\n",
"El 99999999 , NO es perfecto \n"
"Numero a comprobar:6\n",
"El 6 es perfecto\n"
]
}
],
......@@ -1096,10 +1139,84 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 2,
"metadata": {},
"outputs": [],
"source": []
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"la frase \n",
"\n",
"El veloz murciélago hindú comía feliz cardillo y kiwi. La cigüeña tocaba el saxofón detrás del palenque de paja.\n",
"\n",
"Es un panagrama\n"
]
}
],
"source": [
"tex = input(\"la frase \"'\\n' '\\n')\n",
"\n",
"abecedario = list (\"abcdefghijklmnopqrstuvwxyz\")\n",
"\n",
"frase = tex.lower()\n",
"\n",
"i = 0\n",
"\n",
"while i < len (abecedario) :\n",
"\n",
" if abecedario[i] in frase :\n",
" abecedario.pop(i)\n",
" \n",
" else :\n",
" \n",
" i = len(abecedario)\n",
"if len(abecedario) != 0 :\n",
"\n",
" print ('\\n' \"No es un panagrama\")\n",
"\n",
"else :\n",
" \n",
" print ('\\n' \"Es un panagrama\")"
]
},
{
"cell_type": "code",
"execution_count": 11,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"la frase \n",
"\n",
"a\n"
]
},
{
"ename": "NameError",
"evalue": "name 'c' is not defined",
"output_type": "error",
"traceback": [
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[0;31mNameError\u001b[0m Traceback (most recent call last)",
"\u001b[0;32m<ipython-input-11-838e875ade18>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m\u001b[0m\n\u001b[1;32m 6\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 7\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m----> 8\u001b[0;31m \u001b[0mc\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mset\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mc\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 9\u001b[0m \u001b[0mprint\u001b[0m \u001b[0;34m(\u001b[0m\u001b[0mb\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
"\u001b[0;31mNameError\u001b[0m: name 'c' is not defined"
]
}
],
"source": [
"#version con set incompleto\n",
"tex = input(\"la frase \"'\\n' '\\n')\n",
"f = tex.lower()\n",
"\n",
"b = list (\"abcdefghijklmnopqrstuvwxyz\")\n",
"\n",
"\n",
"c = set(c)\n",
"print (b)"
]
},
{
"cell_type": "markdown",
......@@ -1127,10 +1244,30 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 35,
"metadata": {},
"outputs": [],
"source": []
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"\n",
"1\n",
"22\n",
"333\n",
"4444\n",
"55555\n",
"666666\n",
"7777777\n",
"88888888\n",
"999999999\n"
]
}
],
"source": [
"for i in range(10):\n",
" print(str(i) * i)"
]
}
],
"metadata": {
......
......@@ -55,6 +55,7 @@
}
],
"source": [
"a = 1\n",
"type (1)"
]
},
......@@ -75,6 +76,8 @@
}
],
"source": [
"\n",
"\n",
"type (1.)"
]
},
......@@ -224,6 +227,15 @@
"type({\"mensaje\":\"hola mundo\"})"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"d = (\"a\":1, \"b\":2, \"c\":3 )"
]
},
{
"cell_type": "markdown",
"metadata": {},
......@@ -457,7 +469,7 @@
},
{
"cell_type": "code",
"execution_count": 17,
"execution_count": 3,
"metadata": {},
"outputs": [
{
......@@ -467,13 +479,13 @@
"0\n",
"1\n",
"2\n",
"3\n",
"4\n"
"3\n"
]
}
],
"source": [
"for i in range(5):\n",
"i = (\"a\",2,3,0)\n",
"for i in range(4):\n",
" print(i)"
]
},
......@@ -985,6 +997,33 @@
"\n"
]
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {},
"outputs": [
{
"ename": "SyntaxError",
"evalue": "invalid syntax (<ipython-input-7-e6a3d31a7e8b>, line 7)",
"output_type": "error",
"traceback": [
"\u001b[0;36m File \u001b[0;32m\"<ipython-input-7-e6a3d31a7e8b>\"\u001b[0;36m, line \u001b[0;32m7\u001b[0m\n\u001b[0;31m my_set = (set(some:list))\u001b[0m\n\u001b[0m ^\u001b[0m\n\u001b[0;31mSyntaxError\u001b[0m\u001b[0;31m:\u001b[0m invalid syntax\n"
]
}
],
"source": [
"def test_list2set():\n",
" a = [1,2,2,3,3,3,3,4,5,5]\n",
" b =[1,2,3,4,5,]\n",
" print(\"ok\" if list2set(a)==b else \"ko\")\n",
" \n",
"def list2set(some_list):\n",
" my_set = (set(some:list))\n",
" return my_set:\n",
" \n",
"test_list2set()"
]
},
{
"cell_type": "markdown",
"metadata": {},
......@@ -1141,6 +1180,44 @@
" print ('\\n' \"Es un panagrama\")"
]
},
{
"cell_type": "code",
"execution_count": 11,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"la frase \n",
"\n",
"a\n"
]
},
{
"ename": "NameError",
"evalue": "name 'c' is not defined",
"output_type": "error",
"traceback": [
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[0;31mNameError\u001b[0m Traceback (most recent call last)",
"\u001b[0;32m<ipython-input-11-838e875ade18>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m\u001b[0m\n\u001b[1;32m 6\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 7\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m----> 8\u001b[0;31m \u001b[0mc\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mset\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mc\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 9\u001b[0m \u001b[0mprint\u001b[0m \u001b[0;34m(\u001b[0m\u001b[0mb\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
"\u001b[0;31mNameError\u001b[0m: name 'c' is not defined"
]
}
],
"source": [
"#version con set incompleto\n",
"tex = input(\"la frase \"'\\n' '\\n')\n",
"f = tex.lower()\n",
"\n",
"b = list (\"abcdefghijklmnopqrstuvwxyz\")\n",
"\n",
"\n",
"c = set(c)\n",
"print (b)"
]
},
{
"cell_type": "markdown",
"metadata": {},
......
......@@ -46,7 +46,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