Skip to content

Commit

Permalink
Tidying up for publication.
Browse files Browse the repository at this point in the history
  • Loading branch information
jreades committed Oct 6, 2019
1 parent bb4c9db commit 9d14fab
Show file tree
Hide file tree
Showing 7 changed files with 314 additions and 123 deletions.
8 changes: 5 additions & 3 deletions notebook-01.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -629,7 +629,9 @@
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
"source": [
"(2+2+1250)/3"
]
},
{
"cell_type": "markdown",
Expand Down Expand Up @@ -1143,9 +1145,9 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.5"
"version": "3.7.3"
}
},
"nbformat": 4,
"nbformat_minor": 2
"nbformat_minor": 4
}
8 changes: 3 additions & 5 deletions notebook-04.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -483,9 +483,7 @@
},
{
"cell_type": "markdown",
"metadata": {
"collapsed": true
},
"metadata": {},
"source": [
"*The content and structure of this teaching project itself is licensed under the [Creative Commons Attribution-NonCommercial-ShareAlike 4.0 license](https://creativecommons.org/licenses/by-nc-sa/4.0/) , and the contributing source code is licensed under [The MIT License](https://opensource.org/licenses/mit-license.php). *"
]
Expand All @@ -508,9 +506,9 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.5"
"version": "3.7.3"
}
},
"nbformat": 4,
"nbformat_minor": 1
"nbformat_minor": 4
}
10 changes: 4 additions & 6 deletions notebook-05.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"# Notebook-5 Truth & Conditions"
"# Notebook-5: Truth & Conditions"
]
},
{
Expand Down Expand Up @@ -835,9 +835,7 @@
},
{
"cell_type": "markdown",
"metadata": {
"collapsed": true
},
"metadata": {},
"source": []
},
{
Expand Down Expand Up @@ -865,9 +863,9 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.5"
"version": "3.7.3"
}
},
"nbformat": 4,
"nbformat_minor": 1
"nbformat_minor": 4
}
60 changes: 46 additions & 14 deletions notebook-07.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@
"metadata": {},
"outputs": [],
"source": [
"print(myDict[???])"
"print(myDict[\"key2\"])"
]
},
{
Expand Down Expand Up @@ -184,7 +184,8 @@
"outputs": [],
"source": [
"eNumbers = {\n",
" ???\n",
" \"IS\": '112', # It's not very important here whether we use single- or double-quotes\n",
" \"US\": '911'\n",
"}\n",
"print(\"The Icelandic emergency number is \" + eNumbers['IS'])\n",
"print(\"The American emergency number is \" + eNumbers['US']) "
Expand Down Expand Up @@ -220,7 +221,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"Or maybe you just need to access all of the values without trouble to ask for each key:"
"Or maybe you just need to access all of the values without troubling to ask for each key:"
]
},
{
Expand Down Expand Up @@ -355,7 +356,11 @@
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
"source": [
"print(cityData[1][1])\n",
"print(cityData[4][3])\n",
"print(cityData[2][0])"
]
},
{
"cell_type": "markdown",
Expand All @@ -380,8 +385,13 @@
"eNumbers = {\n",
" 'IS': ['Icelandic',112],\n",
" 'US': ['American',911],\n",
" 'FR': ['French',112],\n",
" 'RU': ['Russion',102],\n",
" 'UK': ['British',999]\n",
"}\n",
"print(\"The \" + eNumbers['IS'][0] + \" emergency number is \" + str(eNumbers['IS'][1]))"
"print(\"The \" + eNumbers['IS'][0] + \" emergency number is \" + str(eNumbers['IS'][1]))\n",
"print(\"The \" + eNumbers['RU'][0] + \" emergency number is \" + str(eNumbers['RU'][1]))\n",
"print(\"The \" + eNumbers['UK'][0] + \" emergency number is \" + str(eNumbers['UK'][1]))"
]
},
{
Expand Down Expand Up @@ -447,7 +457,26 @@
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
"source": [
"# Note that we can tweak the formatting a bit: Python is smart \n",
"# enough to understand that if you have a '+' on the end of a\n",
"# string and there next line is also a string then it'll \n",
"# continue to concatenate the string...\n",
"print(\"The population of \" + 'London' + \", the capital of \" + \n",
" cityData2['London']['country']['Full'] + \" (\" + cityData2['London']['country']['ISO2'] + \"), is \" + \n",
" str(cityData2['London']['population']) + \". It has a density of \" + \n",
" str(cityData2['London']['population']/cityData2['London']['area']) + \" persons per square km\")\n",
"\n",
"# But a _better_ way to do this might be one in which we don't\n",
"# hard-code 'London' into the output -- by changing the variable\n",
"# 'c' to Paris we can change the output completely...\n",
"c = 'Paris'\n",
"cd = cityData2[c]\n",
"print(\"The population of \" + c + \", the capital of \" + \n",
" cd['country']['Full'] + \" (\" + cd['country']['ISO2'] + \"), is \" + \n",
" str(cd['population']) + \". It has a density of \" + \n",
" \"{0:8.1f}\".format(cd['population']/cd['area']) + \" persons per square km\")"
]
},
{
"cell_type": "markdown",
Expand Down Expand Up @@ -517,13 +546,13 @@
"latitude = '51.51130657591914'\n",
"\n",
"# Set this up as a coordinate pair \n",
"KCLCoords = [??? , latitude ]\n",
"KCLCoords = [longitude, latitude ]\n",
"\n",
"# How can you assign KCLCoords to \n",
"# the key KCLGeometry[\"coordinates\"]?\n",
"KCLGeometry = {\n",
" \"type\": \"Point\",\n",
" \"coordinates\": ???\n",
" \"coordinates\": KCLCoords\n",
" }\n",
"\n",
"KCL_position = {\n",
Expand Down Expand Up @@ -552,7 +581,12 @@
"# You should see it if you click on the 'Home' tab in your open\n",
"# browser window (it's the one where you started this notebook)\n",
"with open('my-first-marker.geojson', 'w') as outfile:\n",
" json.dump(json.dumps(KCL_position, indent=4), outfile)"
" json.dump(json.dumps(KCL_position, indent=4), outfile)\n",
" \n",
"# And we can also show this in Jupyter directly (it won't show\n",
"# up in the PDF version though)\n",
"from IPython.display import GeoJSON\n",
"GeoJSON(json.dumps(KCL_position, indent=4))"
]
},
{
Expand All @@ -564,9 +598,7 @@
},
{
"cell_type": "markdown",
"metadata": {
"collapsed": true
},
"metadata": {},
"source": [
"**Congratulations on finishing your seventh notebook!**"
]
Expand Down Expand Up @@ -614,9 +646,9 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.5"
"version": "3.7.3"
}
},
"nbformat": 4,
"nbformat_minor": 1
"nbformat_minor": 4
}
Loading

0 comments on commit 9d14fab

Please sign in to comment.