Cambios cgarcia

parent 8cb04f3d
......@@ -774,10 +774,24 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 31,
"metadata": {},
"outputs": [],
"source": []
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"[0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20]\n"
]
}
],
"source": [
"lista=[]\n",
"for i in range (0,21,2):\n",
" lista.append(i)\n",
"\n",
"print(lista)"
]
},
{
"cell_type": "markdown",
......@@ -788,12 +802,29 @@
},
{
"cell_type": "code",
"execution_count": 28,
"execution_count": 40,
"metadata": {},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"[13, 21, 34, 55, 89]\n"
]
}
],
"source": [
"A = [1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89]\n",
"\n"
"\n",
"mayores=[]\n",
"menores=[]\n",
"for numeros in A:\n",
" if numeros>10:\n",
" mayores.append(numeros)\n",
" else:\n",
" menores.append(numeros)\n",
" \n",
"print(mayores)\n"
]
},
{
......@@ -805,12 +836,51 @@
},
{
"cell_type": "code",
"execution_count": 29,
"execution_count": 67,
"metadata": {},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"[1, 1, 2, 3, 5, 8, 13]\n",
"{1, 2, 3, 34, 5, 8, 13, 21, 55, 89}\n",
"{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13}\n"
]
},
{
"ename": "TypeError",
"evalue": "unsupported operand type(s) for +: 'set' and 'set'",
"output_type": "error",
"traceback": [
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[0;31mTypeError\u001b[0m Traceback (most recent call last)",
"\u001b[0;32m<ipython-input-67-885e6668b482>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m\u001b[0m\n\u001b[1;32m 18\u001b[0m \u001b[0mprint\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mA\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 19\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;32m---> 20\u001b[0;31m \u001b[0mA\u001b[0m\u001b[0;34m+\u001b[0m\u001b[0mB\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m",
"\u001b[0;31mTypeError\u001b[0m: unsupported operand type(s) for +: 'set' and 'set'"
]
}
],
"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"
"b = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]\n",
"\n",
"coincide=[]\n",
"no_coincide=[]\n",
"\n",
"for numA in a:\n",
" for numB in b:\n",
" if numA==numB:\n",
" coincide.append(numA)\n",
" else:\n",
" no_coincide.append(numA)\n",
" \n",
"print(coincide)\n",
"\n",
"A=set(a)\n",
"B=set(b)\n",
"print(A)\n",
"print(B)\n",
"A+B"
]
},
{
......@@ -970,7 +1040,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