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

Remove outputs and metadata

This commit is contained in:
J. Fernando Sánchez
2019-02-28 15:30:33 +01:00
parent a1be167cc0
commit c1d3ca38ea
25 changed files with 989 additions and 14268 deletions

View File

@@ -42,9 +42,7 @@
},
{
"cell_type": "markdown",
"metadata": {
"collapsed": true
},
"metadata": {},
"source": [
"## 1. Sets"
]
@@ -52,9 +50,7 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"metadata": {},
"outputs": [],
"source": [
"my_set = set() #create a set\n",
@@ -64,9 +60,7 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"metadata": {},
"outputs": [],
"source": [
"my_set.add(1) # add an element\n",
@@ -76,9 +70,7 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"metadata": {},
"outputs": [],
"source": [
"my_set.add(2) # add another element"
@@ -87,9 +79,7 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"metadata": {},
"outputs": [],
"source": [
"my_set"
@@ -98,9 +88,7 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"metadata": {},
"outputs": [],
"source": [
"my_set.add(3) # add another one\n",
@@ -110,9 +98,7 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"metadata": {},
"outputs": [],
"source": [
"my_set.add(1) #try to add a repeated element\n",
@@ -122,9 +108,7 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"metadata": {},
"outputs": [],
"source": [
"s2 = set(range(10)) # we can create a set from a range\n",
@@ -134,9 +118,7 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"metadata": {},
"outputs": [],
"source": [
"l = ['a', 'a', 'b', 'c', 'c', 'c']"
@@ -145,9 +127,7 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"metadata": {},
"outputs": [],
"source": [
"s3 = set(l) # if we create a set from a list, elements are not repeated\n",
@@ -157,9 +137,7 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"metadata": {},
"outputs": [],
"source": [
"len(s3) "
@@ -168,9 +146,7 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"metadata": {},
"outputs": [],
"source": [
"s3.union(s2) # we can use set methods: union(), intersection(), difference(), ..."
@@ -179,9 +155,7 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"metadata": {},
"outputs": [],
"source": [
"3 in my_set #check membership"
@@ -190,9 +164,7 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"metadata": {},
"outputs": [],
"source": [
"type(s3)"
@@ -208,9 +180,7 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"metadata": {},
"outputs": [],
"source": [
"my_dictionary = {'key1': 1, 'key2': 2, 'key3': 3} # pairs of key-value mappings\n",
@@ -220,9 +190,7 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"metadata": {},
"outputs": [],
"source": [
"my_dictionary['key1'] #retrieve a value given a key"
@@ -231,9 +199,7 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"metadata": {},
"outputs": [],
"source": [
"my_dict = dict()\n",
@@ -246,9 +212,7 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"metadata": {},
"outputs": [],
"source": [
"my_dict == my_dictionary # check if both dictionaries are equal"
@@ -257,9 +221,7 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"metadata": {},
"outputs": [],
"source": [
"my_dict2 = {'one': {'two': {'three': 'Nested dict'}}} #nested dictionary\n",
@@ -269,9 +231,7 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"metadata": {},
"outputs": [],
"source": [
"my_dict2['one']['two']['three'] #access the value"
@@ -279,9 +239,7 @@
},
{
"cell_type": "markdown",
"metadata": {
"collapsed": false
},
"metadata": {},
"source": [
"Dictionaries have different methods, check them with Tab."
]
@@ -289,9 +247,7 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"metadata": {},
"outputs": [],
"source": [
"my_dict.keys() # in Python3 we get a View object that changes when the dictionary changes"
@@ -300,9 +256,7 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"metadata": {},
"outputs": [],
"source": [
"list(my_dict.keys()) # we can convert it to a list, we see dicionaries are unordered"
@@ -311,9 +265,7 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"metadata": {},
"outputs": [],
"source": [
"my_dict.values()"
@@ -322,9 +274,7 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"metadata": {},
"outputs": [],
"source": [
"list(my_dict.values())"
@@ -333,9 +283,7 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"metadata": {},
"outputs": [],
"source": [
"type(my_dict)"