Skip to content

Commit e17b2da

Browse files
committed
Minor changes to session 1 and the README
1 parent f31260d commit e17b2da

2 files changed

Lines changed: 42 additions & 9 deletions

File tree

Introduction_to_python_session_1.ipynb

Lines changed: 39 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,11 @@
9595
"cell_type": "markdown",
9696
"metadata": {},
9797
"source": [
98-
"You can assign a value to a variable with the <tt>=</tt> operator"
98+
"- Very commonly, when programming, we will want to assign a name to some complex expression\n",
99+
"- We can give names to values using _variables_\n",
100+
"- As the name implies, the values stored in a variable can vary\n",
101+
"- You can assign a value to a variable with the <tt>=</tt> operator\n",
102+
"- Note that this is different from mathematical equality (which we will come to later...)"
99103
]
100104
},
101105
{
@@ -173,7 +177,7 @@
173177
"cell_type": "markdown",
174178
"metadata": {},
175179
"source": [
176-
"Variables can be used on the right hand side of an assignment as well"
180+
"Variables can be used on the right hand side of an assignment as well (where they will be evaluated before the value is assigned to the variable on the left hand side)"
177181
]
178182
},
179183
{
@@ -191,7 +195,7 @@
191195
"cell_type": "markdown",
192196
"metadata": {},
193197
"source": [
194-
"Including the current value of a variable itself"
198+
"You can use the current value of a variable itself in an assignment"
195199
]
196200
},
197201
{
@@ -205,6 +209,24 @@
205209
"metadata": {},
206210
"outputs": []
207211
},
212+
{
213+
"cell_type": "markdown",
214+
"metadata": {},
215+
"source": [
216+
"In fact this is such a common idion that there are special operators that will do this implicitly (more on these later)"
217+
]
218+
},
219+
{
220+
"cell_type": "code",
221+
"collapsed": false,
222+
"input": [
223+
"y += 1\n",
224+
"y"
225+
],
226+
"language": "python",
227+
"metadata": {},
228+
"outputs": []
229+
},
208230
{
209231
"cell_type": "heading",
210232
"level": 2,
@@ -217,6 +239,8 @@
217239
"cell_type": "markdown",
218240
"metadata": {},
219241
"source": [
242+
"Python (and computers in general) treats different types of data differently. Python has 5 (or possibly 6) main basic data types.\n",
243+
"\n",
220244
"Booleans:"
221245
]
222246
},
@@ -359,6 +383,11 @@
359383
"Arithmetic"
360384
]
361385
},
386+
{
387+
"cell_type": "markdown",
388+
"metadata": {},
389+
"source": []
390+
},
362391
{
363392
"cell_type": "code",
364393
"collapsed": false,
@@ -371,7 +400,7 @@
371400
"x % y # remainder of x/y\n",
372401
"x ** y # exponentiation\n",
373402
"pow(x, y) # another way to do exponentiation\n",
374-
"print (x - y) * 4"
403+
"print ((x + 1) - y) * 4"
375404
],
376405
"language": "python",
377406
"metadata": {},
@@ -477,6 +506,8 @@
477506
"cell_type": "markdown",
478507
"metadata": {},
479508
"source": [
509+
"As well as the basic data types we introduced above, very commonly you will want to store and operate on collections of values, and python has several _data structures_ that you can use to do this. Which one you will use will depend on what problem you are trying to solve.\n",
510+
"\n",
480511
"__Tuples__: fixed collections of values of mixed types"
481512
]
482513
},
@@ -558,7 +589,7 @@
558589
"cell_type": "markdown",
559590
"metadata": {},
560591
"source": [
561-
"__Lists__: mutable collections of values, i.e. lists can be altered once built"
592+
"__Lists__: mutable collections of values, i.e. lists _can_ be altered once initialised"
562593
]
563594
},
564595
{
@@ -600,7 +631,7 @@
600631
"cell_type": "markdown",
601632
"metadata": {},
602633
"source": [
603-
"Manipulating tuples and lists: these can be used in very similar ways"
634+
"__Manipulating tuples and lists:__ these two types can be used in very similar ways"
604635
]
605636
},
606637
{
@@ -872,7 +903,7 @@
872903
"cell_type": "markdown",
873904
"metadata": {},
874905
"source": [
875-
"Note that both of these change the list, if you want a sorted copy of the list, use <tt>sorted</tt>"
906+
"Note that both of these change the list, if you want a sorted copy of the list while leaving the original untouched, use <tt>sorted</tt>"
876907
]
877908
},
878909
{
@@ -901,7 +932,7 @@
901932
"source": [
902933
"__String manipulations__\n",
903934
"\n",
904-
"Strings are a lot like tuples, and individual characters and substrings can be accessed and manipulated using similar operations\n"
935+
"Strings are a lot like tuples of characters, and individual characters and substrings can be accessed and manipulated using similar operations\n"
905936
]
906937
},
907938
{

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
python-course
2-
=============
2+
=============
3+
4+
Materials for the "Introduction to Solving Biological Problems with Python" course run by the Graduate School of Life Sciences, University of Cambridge.

0 commit comments

Comments
 (0)