1
0
mirror of https://github.com/gsi-upm/sitc synced 2025-12-15 09:38:16 +00:00

Updated to 2016 and clean cells

This commit is contained in:
cif2cif
2016-02-15 09:01:37 +01:00
parent 39897634b6
commit 4ffb1a1891
11 changed files with 353 additions and 2013 deletions

View File

@@ -18,7 +18,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"Department of Telematic Engineering Systems, Universidad Politécnica de Madrid, © 2015 Carlos A. Iglesias"
"Department of Telematic Engineering Systems, Universidad Politécnica de Madrid, © 2016 Carlos A. Iglesias"
]
},
{
@@ -51,22 +51,11 @@
},
{
"cell_type": "code",
"execution_count": 413,
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
"set()"
]
},
"execution_count": 413,
"metadata": {},
"output_type": "execute_result"
}
],
"outputs": [],
"source": [
"my_set = set() #create a set\n",
"my_set"
@@ -74,22 +63,11 @@
},
{
"cell_type": "code",
"execution_count": 414,
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
"{1}"
]
},
"execution_count": 414,
"metadata": {},
"output_type": "execute_result"
}
],
"outputs": [],
"source": [
"my_set.add(1) # add an element\n",
"my_set"
@@ -97,7 +75,7 @@
},
{
"cell_type": "code",
"execution_count": 415,
"execution_count": null,
"metadata": {
"collapsed": false
},
@@ -108,44 +86,22 @@
},
{
"cell_type": "code",
"execution_count": 416,
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
"{1, 2}"
]
},
"execution_count": 416,
"metadata": {},
"output_type": "execute_result"
}
],
"outputs": [],
"source": [
"my_set"
]
},
{
"cell_type": "code",
"execution_count": 417,
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
"{1, 2, 3}"
]
},
"execution_count": 417,
"metadata": {},
"output_type": "execute_result"
}
],
"outputs": [],
"source": [
"my_set.add(3) # add another one\n",
"my_set"
@@ -153,22 +109,11 @@
},
{
"cell_type": "code",
"execution_count": 418,
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
"{1, 2, 3}"
]
},
"execution_count": 418,
"metadata": {},
"output_type": "execute_result"
}
],
"outputs": [],
"source": [
"my_set.add(1) #try to add a repeated element\n",
"my_set"
@@ -176,22 +121,11 @@
},
{
"cell_type": "code",
"execution_count": 419,
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
"{0, 1, 2, 3, 4, 5, 6, 7, 8, 9}"
]
},
"execution_count": 419,
"metadata": {},
"output_type": "execute_result"
}
],
"outputs": [],
"source": [
"s2 = set(range(10)) # we can create a set from a range\n",
"s2"
@@ -199,7 +133,7 @@
},
{
"cell_type": "code",
"execution_count": 420,
"execution_count": null,
"metadata": {
"collapsed": false
},
@@ -210,22 +144,11 @@
},
{
"cell_type": "code",
"execution_count": 421,
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
"{'a', 'b', 'c'}"
]
},
"execution_count": 421,
"metadata": {},
"output_type": "execute_result"
}
],
"outputs": [],
"source": [
"s3 = set(l) # if we create a set from a list, elements are not repeated\n",
"s3"
@@ -233,88 +156,44 @@
},
{
"cell_type": "code",
"execution_count": 422,
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
"3"
]
},
"execution_count": 422,
"metadata": {},
"output_type": "execute_result"
}
],
"outputs": [],
"source": [
"len(s3) "
]
},
{
"cell_type": "code",
"execution_count": 423,
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
"{0, 1, 2, 3, 4, 5, 'c', 6, 7, 8, 9, 'a', 'b'}"
]
},
"execution_count": 423,
"metadata": {},
"output_type": "execute_result"
}
],
"outputs": [],
"source": [
"s3.union(s2) # we can use set methods: union(), intersection(), difference(), ..."
]
},
{
"cell_type": "code",
"execution_count": 424,
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
"True"
]
},
"execution_count": 424,
"metadata": {},
"output_type": "execute_result"
}
],
"outputs": [],
"source": [
"3 in my_set #check membership"
]
},
{
"cell_type": "code",
"execution_count": 425,
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
"set"
]
},
"execution_count": 425,
"metadata": {},
"output_type": "execute_result"
}
],
"outputs": [],
"source": [
"type(s3)"
]
@@ -328,22 +207,11 @@
},
{
"cell_type": "code",
"execution_count": 426,
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
"{'key1': 1, 'key2': 2, 'key3': 3}"
]
},
"execution_count": 426,
"metadata": {},
"output_type": "execute_result"
}
],
"outputs": [],
"source": [
"my_dictionary = {'key1': 1, 'key2': 2, 'key3': 3} # pairs of key-value mappings\n",
"my_dictionary"
@@ -351,44 +219,22 @@
},
{
"cell_type": "code",
"execution_count": 427,
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
"1"
]
},
"execution_count": 427,
"metadata": {},
"output_type": "execute_result"
}
],
"outputs": [],
"source": [
"my_dictionary['key1'] #retrieve a value given a key"
]
},
{
"cell_type": "code",
"execution_count": 428,
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
"{'key1': 1, 'key2': 2, 'key3': 3}"
]
},
"execution_count": 428,
"metadata": {},
"output_type": "execute_result"
}
],
"outputs": [],
"source": [
"my_dict = dict()\n",
"my_dict['key1'] = 1\n",
@@ -399,44 +245,22 @@
},
{
"cell_type": "code",
"execution_count": 429,
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
"True"
]
},
"execution_count": 429,
"metadata": {},
"output_type": "execute_result"
}
],
"outputs": [],
"source": [
"my_dict == my_dictionary # check if both dictionaries are equal"
]
},
{
"cell_type": "code",
"execution_count": 430,
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
"{'one': {'two': {'three': 'Nested dict'}}}"
]
},
"execution_count": 430,
"metadata": {},
"output_type": "execute_result"
}
],
"outputs": [],
"source": [
"my_dict2 = {'one': {'two': {'three': 'Nested dict'}}} #nested dictionary\n",
"my_dict2"
@@ -444,22 +268,11 @@
},
{
"cell_type": "code",
"execution_count": 431,
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
"'Nested dict'"
]
},
"execution_count": 431,
"metadata": {},
"output_type": "execute_result"
}
],
"outputs": [],
"source": [
"my_dict2['one']['two']['three'] #access the value"
]
@@ -475,110 +288,55 @@
},
{
"cell_type": "code",
"execution_count": 473,
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
"dict_keys(['key2', 'key3', 'key1'])"
]
},
"execution_count": 473,
"metadata": {},
"output_type": "execute_result"
}
],
"outputs": [],
"source": [
"my_dict.keys() # in Python3 we get a View object that changes when the dictionary changes"
]
},
{
"cell_type": "code",
"execution_count": 478,
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
"['key2', 'key3', 'key1']"
]
},
"execution_count": 478,
"metadata": {},
"output_type": "execute_result"
}
],
"outputs": [],
"source": [
"list(my_dict.keys()) # we can convert it to a list, we see dicionaries are unordered"
]
},
{
"cell_type": "code",
"execution_count": 474,
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
"dict_values([2, 3, 1])"
]
},
"execution_count": 474,
"metadata": {},
"output_type": "execute_result"
}
],
"outputs": [],
"source": [
"my_dict.values()"
]
},
{
"cell_type": "code",
"execution_count": 476,
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
"[2, 3, 1]"
]
},
"execution_count": 476,
"metadata": {},
"output_type": "execute_result"
}
],
"outputs": [],
"source": [
"list(my_dict.values())"
]
},
{
"cell_type": "code",
"execution_count": 479,
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
"dict"
]
},
"execution_count": 479,
"metadata": {},
"output_type": "execute_result"
}
],
"outputs": [],
"source": [
"type(my_dict)"
]
@@ -596,7 +354,7 @@
"source": [
"The notebook is freely licensed under under the [Creative Commons Attribution Share-Alike license](https://creativecommons.org/licenses/by/2.0/). \n",
"\n",
"© 2015 Carlos A. Iglesias, Universidad Politécnica de Madrid."
"© 2016 Carlos A. Iglesias, Universidad Politécnica de Madrid."
]
}
],
@@ -616,7 +374,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.4.3+"
"version": "3.5.1"
}
},
"nbformat": 4,