Skip to content

Commit 7e091e0

Browse files
author
Philip Guo
committed
lesson modified
1 parent 0e32fe0 commit 7e091e0

3 files changed

Lines changed: 15 additions & 27 deletions

File tree

‎v3/css/opt-lessons.css‎

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,5 @@
11
/* CSS accompanying ../lesson.html */
22

3-
h1 {
4-
font-weight: normal;
5-
font-size: 20pt;
6-
font-family: georgia, serif;
7-
line-height: 1em; /* enforce single spacing so that Georgia works */
8-
9-
margin-top: 0px;
10-
margin-bottom: 8px;
11-
}
12-
13-
h2 {
14-
font-size: 12pt;
15-
font-weight: normal;
16-
font-family: georgia, serif;
17-
line-height: 1.1em; /* enforce single spacing so that Georgia works */
18-
19-
margin-top: 2px;
20-
margin-bottom: 20px;
21-
}
22-
23-
243
body {
254
background-color: white;
265

‎v3/lesson.html‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,9 @@
5555
<div id="lessonTitle"></div>
5656
<div id="lessonDescription"></div>
5757

58+
<div id="lessonNarration"></div>
5859
</div>
5960

60-
<div id="lessonNarration"></div>
61-
6261
<div id="pyOutputPane">
6362
</div>
6463

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,21 @@
1-
li = ["a", "b", "mpilgrim", "z", "example"]
1+
li = ['a', 'b', 'mp', 'z', 'e']
22
slice1 = li[1:3]
33
slice2 = li[1:-1]
44
slice3 = li[0:3]
55
li.append("new")
66
li.insert(2, "new")
77
li.extend(["two", "elements"])
8+
li.remove("z")
9+
li.remove("new")
10+
li.remove("new")
11+
li.remove("c")
812
======
913
{
1014
"title": "Basic List Operations",
1115

1216
"description": "This lesson was derived from Section 3.2 of <a href='http://www.diveintopython.net/native_data_types/lists.html'>Dive Into Python</a>.",
1317

14-
"1": "First, you define a list of five elements. Note that they retain their original order. This is not an accident. A list is an ordered set of elements enclosed in square brackets.",
18+
"1": "First, you define a list of five elements. Note that after you execute this line, the elements retain their original order. This is not an accident. A list is an ordered set of elements enclosed in square brackets.",
1519

1620
"2": "You can get a subset of a list, called a \"slice\", by specifying two indices. The return value is a new list containing all the elements of the list, in order, starting with the first slice index (in this case <code>li[1]</code>), up to but not including the second slice index (in this case <code>li[3]</code>).",
1721

@@ -21,8 +25,14 @@ li.extend(["two", "elements"])
2125

2226
"5": "<code>append</code> adds a single element to the end of the list.",
2327

24-
"6": "<code>insert</code> inserts a single element into a list. The numeric argument is the index of the first element that gets bumped out of position. Note that list elements do not need to be unique; there are now two separate elements with the value '<code>new</code>', <code>li[2]</code> and <code>li[6]</code>.",
28+
"6": "<code>insert</code> inserts a single element into a list. The numeric argument is the index of the first element that gets bumped out of position. Note that list elements do not need to be unique; there will now be two separate elements with the value '<code>new</code>', <code>li[2]</code> and <code>li[6]</code>.",
2529

26-
"7": "<code>extend</code> concatenates lists. Note that you do not call <code>extend</code> with multiple arguments; you call it with one argument, a list. In this case, that list has two elements."
30+
"7": "<code>extend</code> concatenates lists. Note that you do not call <code>extend</code> with multiple arguments; you call it with one argument, a list. In this case, that list has two elements.",
31+
32+
"8": "<code>remove</code> removes the first occurrence of a value from a list.",
33+
34+
"9": "<code>remove</code> removes <i>only</i> the first occurrence of a value. In this case, '<code>new</code>' appears twice in the list, but <code>li.remove(\"new\")</code> will remove only the first occurrence.",
35+
36+
"11": "If the value is not found in the list, Python raises an exception. This mirrors the behavior of the <code>index</code> method."
2737

2838
}

0 commit comments

Comments
 (0)