Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
tap1012
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
3
Merge Requests
3
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Mario Chirinos Colunga
tap1012
Commits
4ae3710f
Commit
4ae3710f
authored
Jan 22, 2019
by
Alejandro Molina Villegas
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
01-DataTypes&ControlFlow.ipynb
parent
ef53495a
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
149 additions
and
31 deletions
+149
-31
01-DataTypes&ControlFlow.ipynb
01-DataTypes&ControlFlow.ipynb
+149
-31
No files found.
01-DataTypes&ControlFlow.ipynb
View file @
4ae3710f
...
...
@@ -78,6 +78,33 @@
"type (1.)"
]
},
{
"cell_type": "code",
"execution_count": 30,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"<class 'int'>\n",
"<class 'float'>\n",
"<class 'float'>\n",
"<class 'float'> 0\n"
]
}
],
"source": [
"a=1\n",
"print(type(a))\n",
"b=2.0\n",
"c=2\n",
"print(type(a+b))\n",
"print(type(a/b))\n",
"\n",
"print(type(a/c), int(a/c))"
]
},
{
"cell_type": "code",
"execution_count": 3,
...
...
@@ -130,22 +157,54 @@
},
{
"cell_type": "code",
"execution_count":
5
,
"execution_count":
18
,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"tuple"
]
},
"execution_count": 5,
"metadata": {},
"output_type": "execute_result"
"name": "stdout",
"output_type": "stream",
"text": [
"<class 'tuple'>\n"
]
},
{
"ename": "TypeError",
"evalue": "'tuple' object does not support item assignment",
"output_type": "error",
"traceback": [
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[0;31mTypeError\u001b[0m Traceback (most recent call last)",
"\u001b[0;32m<ipython-input-18-e12d2c827d71>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m\u001b[0m\n\u001b[1;32m 1\u001b[0m \u001b[0mmitupla\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0;34m(\u001b[0m\u001b[0;36m1\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;36m2\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;36m3\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m\"hola mundo\"\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 2\u001b[0m \u001b[0mprint\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mtype\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mmitupla\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m----> 3\u001b[0;31m \u001b[0mmitupla\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;36m1\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;36m4\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m",
"\u001b[0;31mTypeError\u001b[0m: 'tuple' object does not support item assignment"
]
}
],
"source": [
"mitupla = (1,2,3, \"hola mundo\")\n",
"print(type(mitupla))\n",
"mitupla[1]=4"
]
},
{
"cell_type": "code",
"execution_count": 20,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"<class 'list'>\n",
"[1, 4, 3, 'hola mundo']\n"
]
}
],
"source": [
"type((1,2))"
"milista = [1,2,3, \"hola mundo\"]\n",
"print(type(milista))\n",
"milista[1]=4\n",
"\n",
"print(milista)"
]
},
{
...
...
@@ -206,22 +265,68 @@
},
{
"cell_type": "code",
"execution_count":
8
,
"execution_count":
23
,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"dict"
]
},
"execution_count": 8,
"metadata": {},
"output_type": "execute_result"
"name": "stdout",
"output_type": "stream",
"text": [
"<class 'dict'>\n",
"<class 'list'>\n"
]
}
],
"source": [
"mid={\"mensaje\":1, \"men2\":4}\n",
"print(type(mid))\n",
"mid=[{\"mensaje\":1, \"men2\":4}]\n",
"print((type(mid)))"
]
},
{
"cell_type": "code",
"execution_count": 42,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"('a', 1)\n",
"('b', 2)\n",
"('c', 3)\n",
"a\n",
"b\n",
"c\n",
"1\n",
"2\n",
"3\n",
"a 1\n",
"b 2\n",
"Beto\n",
"c 3\n",
"<class 'dict_items'>\n"
]
}
],
"source": [
"type({\"mensaje\":\"hola mundo\"})"
"d={\"a\":1, \"b\":2, \"c\":3}\n",
"for i in d.items():\n",
" print(i)\n",
"\n",
"for k in d.keys():\n",
" print(k)\n",
"\n",
"for k in d.values():\n",
" print(k)\n",
"\n",
"for (k, v) in d.items():\n",
" print(k, v)\n",
" if k=='b':\n",
" print('Beto')\n",
"\n",
"print(type(d.items()))"
]
},
{
...
...
@@ -457,23 +562,22 @@
},
{
"cell_type": "code",
"execution_count":
17
,
"execution_count":
32
,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"0\n",
"1\n",
"a\n",
"2\n",
"3\n",
"4\n"
"5.0\n"
]
}
],
"source": [
"for i in range(5):\n",
"l=[\"a\",2,5.0]\n",
"for i in l:\n",
" print(i)"
]
},
...
...
@@ -855,16 +959,31 @@
},
{
"cell_type": "code",
"execution_count":
null
,
"execution_count":
46
,
"metadata": {},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"<class 'list'>\n",
"<class 'set'> {1, 2, 3, 4, 5}\n",
"<class 'list'> [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",
"print(type(a))\n",
"sa=set(a)\n",
"print(type(sa),sa)\n",
"a=list(sa)\n",
"print(type(a),a)"
]
},
{
"cell_type": "code",
"execution_count":
13
,
"execution_count":
48
,
"metadata": {},
"outputs": [
{
...
...
@@ -996,7 +1115,6 @@
"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",
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment