Commit 941b67c4 authored by alan's avatar alan

apuntes clases

parent 42ada44a
...@@ -55,6 +55,7 @@ ...@@ -55,6 +55,7 @@
} }
], ],
"source": [ "source": [
"a = 1\n",
"type (1)" "type (1)"
] ]
}, },
...@@ -75,6 +76,8 @@ ...@@ -75,6 +76,8 @@
} }
], ],
"source": [ "source": [
"\n",
"\n",
"type (1.)" "type (1.)"
] ]
}, },
...@@ -224,6 +227,15 @@ ...@@ -224,6 +227,15 @@
"type({\"mensaje\":\"hola mundo\"})" "type({\"mensaje\":\"hola mundo\"})"
] ]
}, },
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"d = (\"a\":1, \"b\":2, \"c\":3 )"
]
},
{ {
"cell_type": "markdown", "cell_type": "markdown",
"metadata": {}, "metadata": {},
...@@ -457,7 +469,7 @@ ...@@ -457,7 +469,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 17, "execution_count": 3,
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
{ {
...@@ -467,13 +479,13 @@ ...@@ -467,13 +479,13 @@
"0\n", "0\n",
"1\n", "1\n",
"2\n", "2\n",
"3\n", "3\n"
"4\n"
] ]
} }
], ],
"source": [ "source": [
"for i in range(5):\n", "i = (\"a\",2,3,0)\n",
"for i in range(4):\n",
" print(i)" " print(i)"
] ]
}, },
...@@ -875,7 +887,7 @@ ...@@ -875,7 +887,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 160, "execution_count": 5,
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
{ {
...@@ -883,7 +895,7 @@ ...@@ -883,7 +895,7 @@
"output_type": "stream", "output_type": "stream",
"text": [ "text": [
"Cuantos numeros de Fibonacci desea:\n", "Cuantos numeros de Fibonacci desea:\n",
"10\n", "15\n",
"[1]\n", "[1]\n",
"[1, 1]\n", "[1, 1]\n",
"[1, 1, 2]\n", "[1, 1, 2]\n",
...@@ -893,13 +905,17 @@ ...@@ -893,13 +905,17 @@
"[1, 1, 2, 3, 5, 8, 13]\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]\n",
"[1, 1, 2, 3, 5, 8, 13, 21, 34]\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": [ "source": [
"def fibonacci(n):\n", "\n",
" pass\n",
"a = 0\n", "a = 0\n",
"b = 1\n", "b = 1\n",
"fib = []\n", "fib = []\n",
...@@ -981,6 +997,33 @@ ...@@ -981,6 +997,33 @@
"\n" "\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", "cell_type": "markdown",
"metadata": {}, "metadata": {},
...@@ -993,15 +1036,15 @@ ...@@ -993,15 +1036,15 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 26, "execution_count": 2,
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
{ {
"name": "stdout", "name": "stdout",
"output_type": "stream", "output_type": "stream",
"text": [ "text": [
"Numero a comprobar:99999999\n", "Numero a comprobar:6\n",
"El 99999999 , NO es perfecto \n" "El 6 es perfecto\n"
] ]
} }
], ],
...@@ -1096,10 +1139,84 @@ ...@@ -1096,10 +1139,84 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": null, "execution_count": 2,
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [
"source": [] {
"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", "cell_type": "markdown",
...@@ -1127,10 +1244,30 @@ ...@@ -1127,10 +1244,30 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": null, "execution_count": 35,
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [
"source": [] {
"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": { "metadata": {
......
...@@ -55,6 +55,7 @@ ...@@ -55,6 +55,7 @@
} }
], ],
"source": [ "source": [
"a = 1\n",
"type (1)" "type (1)"
] ]
}, },
...@@ -75,6 +76,8 @@ ...@@ -75,6 +76,8 @@
} }
], ],
"source": [ "source": [
"\n",
"\n",
"type (1.)" "type (1.)"
] ]
}, },
...@@ -224,6 +227,15 @@ ...@@ -224,6 +227,15 @@
"type({\"mensaje\":\"hola mundo\"})" "type({\"mensaje\":\"hola mundo\"})"
] ]
}, },
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"d = (\"a\":1, \"b\":2, \"c\":3 )"
]
},
{ {
"cell_type": "markdown", "cell_type": "markdown",
"metadata": {}, "metadata": {},
...@@ -457,7 +469,7 @@ ...@@ -457,7 +469,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 17, "execution_count": 3,
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
{ {
...@@ -467,13 +479,13 @@ ...@@ -467,13 +479,13 @@
"0\n", "0\n",
"1\n", "1\n",
"2\n", "2\n",
"3\n", "3\n"
"4\n"
] ]
} }
], ],
"source": [ "source": [
"for i in range(5):\n", "i = (\"a\",2,3,0)\n",
"for i in range(4):\n",
" print(i)" " print(i)"
] ]
}, },
...@@ -985,6 +997,33 @@ ...@@ -985,6 +997,33 @@
"\n" "\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", "cell_type": "markdown",
"metadata": {}, "metadata": {},
...@@ -1141,6 +1180,44 @@ ...@@ -1141,6 +1180,44 @@
" print ('\\n' \"Es un panagrama\")" " 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", "cell_type": "markdown",
"metadata": {}, "metadata": {},
......
...@@ -46,7 +46,7 @@ ...@@ -46,7 +46,7 @@
"name": "python", "name": "python",
"nbconvert_exporter": "python", "nbconvert_exporter": "python",
"pygments_lexer": "ipython3", "pygments_lexer": "ipython3",
"version": "3.5.3" "version": "3.5.2"
} }
}, },
"nbformat": 4, "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