para la clase

parent 52887fb8
......@@ -855,13 +855,39 @@
},
{
"cell_type": "code",
"execution_count": 32,
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"a = [1,2,2,3,3,3,3,4,5,5]"
]
},
{
"cell_type": "code",
"execution_count": 13,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"OK\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 = list(set(some_list))\n",
" return my_set\n",
"\n",
"test_list2set()"
]
},
{
"cell_type": "markdown",
"metadata": {},
......@@ -922,6 +948,72 @@
"[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": 9,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"a True\n",
"b True\n",
"c True\n",
"d True\n",
"e True\n",
"f True\n",
"g True\n",
"h True\n",
"i True\n",
"j True\n",
"k True\n",
"l True\n",
"m True\n",
"n True\n",
"ñ True\n",
"o True\n",
"p True\n",
"q True\n",
"r True\n",
"s True\n",
"t True\n",
"u True\n",
"v True\n",
"w True\n",
"x True\n",
"y True\n",
"z True\n",
"27 True\n",
"a True\n",
"b False\n",
"2 False\n",
"OK\n"
]
}
],
"source": [
"def test_pangram():\n",
" pangram = \"jovencillo emponzoñado de whisky , qué figurota exhibe !\"\n",
" nopangram = \"Agua pasa por mi casa\"\n",
"\n",
" print(\"OK\" if is_pangram(pangram) and not is_pangram(nopangram) else \"KO\")\n",
"\n",
"def is_pangram(string):\n",
" alfabet = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'ñ', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']\n",
" i = 0\n",
" for char in alfabet:\n",
" char_included = char in string\n",
" print(char, char_included)\n",
" i += 1\n",
" if not char_included:\n",
" break\n",
" print(i, i==len(alfabet))\n",
" return(i==len(alfabet))\n",
"\n",
"test_pangram()"
]
},
{
"cell_type": "markdown",
"metadata": {},
......
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