Skip to content

Commit 726ed10

Browse files
committed
updates
1 parent acb3518 commit 726ed10

File tree

2 files changed

+115
-9
lines changed

2 files changed

+115
-9
lines changed

10-sequences.ipynb

+76-9
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@
140140
},
141141
{
142142
"cell_type": "code",
143-
"execution_count": 4,
143+
"execution_count": 1,
144144
"metadata": {
145145
"cell_style": "split",
146146
"slideshow": {
@@ -160,9 +160,9 @@
160160
],
161161
"source": [
162162
"a = [12, 32, 4, 39, 24]\n",
163-
"print('a[-1] =', a[-1])\n",
163+
"print('a[-1] =', a[-1]) # a[len(a) - 1]\n",
164164
"print('a[2] =', a[2])\n",
165-
"print('a[-2] =', a[-2])"
165+
"print('a[-2] =', a[-2]) # a[len(a) - 2]"
166166
]
167167
},
168168
{
@@ -318,6 +318,17 @@
318318
" print(a[i])"
319319
]
320320
},
321+
{
322+
"cell_type": "markdown",
323+
"metadata": {
324+
"slideshow": {
325+
"slide_type": "subslide"
326+
}
327+
},
328+
"source": [
329+
"### Traversing a list in a Pythonic way "
330+
]
331+
},
321332
{
322333
"cell_type": "code",
323334
"execution_count": 7,
@@ -340,7 +351,6 @@
340351
}
341352
],
342353
"source": [
343-
"# Traversing a list in a Pythonic way \n",
344354
"for value in a:\n",
345355
" print(value)"
346356
]
@@ -364,7 +374,7 @@
364374
}
365375
},
366376
"source": [
367-
"#### append will add an element to the end of the list"
377+
"#### `append` will add an element to the end of the list"
368378
]
369379
},
370380
{
@@ -548,7 +558,10 @@
548558
}
549559
},
550560
"source": [
551-
"#### insert will insert an element at a particular index in the list"
561+
"#### insert will insert an element at a particular index in the list\n",
562+
"```py\n",
563+
"list.insert(index, object)\n",
564+
"```"
552565
]
553566
},
554567
{
@@ -739,7 +752,8 @@
739752
}
740753
},
741754
"source": [
742-
"### Sort a list"
755+
"### Sort a list\n",
756+
"The built-in sort function uses an algorithm known as [Tim Sort](https://en.wikipedia.org/wiki/Timsort)."
743757
]
744758
},
745759
{
@@ -972,6 +986,8 @@
972986
"```py\n",
973987
"list.remove(value) # removes value from the list\n",
974988
"removed_value = list.pop(index) # removes value at index and returns it\n",
989+
"last_value = list.pop() # removes the last value and returns it\n",
990+
"del list[index] # deletes value from list at index\n",
975991
"```"
976992
]
977993
},
@@ -1086,7 +1102,8 @@
10861102
"## tuple\n",
10871103
"- A list of comma separated values enclosed within parentheses.\n",
10881104
"- heterogeneous (it can have values of any type)\n",
1089-
"- immutable"
1105+
"- immutable\n",
1106+
"- supports negative indexing"
10901107
]
10911108
},
10921109
{
@@ -1582,7 +1599,7 @@
15821599
}
15831600
},
15841601
"source": [
1585-
"### Count number of a particular substring"
1602+
"### Count number of occurrences of a particular substring"
15861603
]
15871604
},
15881605
{
@@ -1807,6 +1824,56 @@
18071824
"***"
18081825
]
18091826
},
1827+
{
1828+
"cell_type": "markdown",
1829+
"metadata": {
1830+
"slideshow": {
1831+
"slide_type": "slide"
1832+
}
1833+
},
1834+
"source": [
1835+
"### A few extras"
1836+
]
1837+
},
1838+
{
1839+
"cell_type": "code",
1840+
"execution_count": 5,
1841+
"metadata": {
1842+
"slideshow": {
1843+
"slide_type": "fragment"
1844+
}
1845+
},
1846+
"outputs": [
1847+
{
1848+
"name": "stdout",
1849+
"output_type": "stream",
1850+
"text": [
1851+
"C\n",
1852+
"88\n"
1853+
]
1854+
}
1855+
],
1856+
"source": [
1857+
"ascii_value = 67\n",
1858+
"character = chr(ascii_value)\n",
1859+
"print(character)\n",
1860+
"\n",
1861+
"character = 'X'\n",
1862+
"ascii_value = ord(character)\n",
1863+
"print(ascii_value)"
1864+
]
1865+
},
1866+
{
1867+
"cell_type": "markdown",
1868+
"metadata": {
1869+
"slideshow": {
1870+
"slide_type": "skip"
1871+
}
1872+
},
1873+
"source": [
1874+
"***"
1875+
]
1876+
},
18101877
{
18111878
"cell_type": "markdown",
18121879
"metadata": {

16-lists-2.ipynb

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
{
2+
"cells": [
3+
{
4+
"cell_type": "markdown",
5+
"metadata": {},
6+
"source": [
7+
"### 2D lists and more"
8+
]
9+
},
10+
{
11+
"cell_type": "code",
12+
"execution_count": null,
13+
"metadata": {},
14+
"outputs": [],
15+
"source": []
16+
}
17+
],
18+
"metadata": {
19+
"kernelspec": {
20+
"display_name": "Python 3",
21+
"language": "python",
22+
"name": "python3"
23+
},
24+
"language_info": {
25+
"codemirror_mode": {
26+
"name": "ipython",
27+
"version": 3
28+
},
29+
"file_extension": ".py",
30+
"mimetype": "text/x-python",
31+
"name": "python",
32+
"nbconvert_exporter": "python",
33+
"pygments_lexer": "ipython3",
34+
"version": "3.7.0"
35+
}
36+
},
37+
"nbformat": 4,
38+
"nbformat_minor": 2
39+
}

0 commit comments

Comments
 (0)