Skip to content

Commit 448b0ac

Browse files
committed
edits
1 parent f98e99b commit 448b0ac

7 files changed

Lines changed: 69 additions & 29 deletions

File tree

Notes/01_Introduction/01_Python.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22

33
In this part, we'll start with the absolute basics of Python.
44

5-
## Reading
6-
75
### What is Python?
86

97
Python is an interpreted high level programming language. It is often classified as a

Notes/01_Introduction/02_Hello_world.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
This section discusses the creation of your first program, running the interpreter,
44
and some basic debugging.
55

6-
## Reading
7-
86
### Running Python
97

108
Python programs run inside an interpreter.

Notes/01_Introduction/04_Strings.md

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22

33
This section covers the basics of text manipulation.
44

5-
## Reading
6-
75
### Representing Text
86

97
String are text literals written in programs with quotes.
@@ -28,6 +26,9 @@ Triple quotes capture all text enclosed in multiple lines.
2826

2927
### String escape codes
3028

29+
Escape codes are used to represent control characters and characters that can't be easily typed
30+
at the keyboard. Here are some common escape codes:
31+
3132
```
3233
'\n' Line feed
3334
'\r' Carriage return
@@ -36,7 +37,6 @@ Triple quotes capture all text enclosed in multiple lines.
3637
'\"' Literal double quote
3738
'\\'` Literal backslash
3839
```
39-
These codes are inspired by C.
4040

4141
### String Representation
4242

@@ -45,9 +45,9 @@ Each character represents a raw unicode code point.
4545
<!-- TODO: Add Picture of following characters -->
4646

4747
```python
48-
a = '\xf1' # a = 'ñ'
49-
b = '\u2200' # b = '∀'
50-
c = '\U0001D122' # c = '𝄢'
48+
a = '\xf1' # a = 'ñ'
49+
b = '\u2200' # b = '∀'
50+
c = '\U0001D122' # c = '𝄢'
5151
d = '\N{FORALL}' # d = '∀'
5252
```
5353

@@ -114,11 +114,13 @@ Replacing text.
114114

115115
```python
116116
s = 'Hello world'
117-
t = s.replace('Hello' , 'Hallo')
117+
t = s.replace('Hello' , 'Hallo') # 'Hallo world'
118118
```
119119

120120
**More string methods:**
121121

122+
Strings have a wide variety of other methods for testing and manipulating the text data:
123+
122124
```python
123125
s.endswith(suffix) # Check if string ends with suffix
124126
s.find(t) # First occurrence of t in s
@@ -136,11 +138,11 @@ s.split([delim]) # Split string into list of substrings
136138
s.startswith(prefix) # Check if string starts with prefix
137139
s.strip() # Strip leading/trailing space
138140
s.upper() # Convert to upper case
141+
```
139142

140143
### String Mutability
141144

142-
Strings are "immutable". They are read only.
143-
145+
Strings are "immutable" or read-only.
144146
Once created, the value can't be changed.
145147

146148
```python
@@ -198,20 +200,20 @@ data = text.encode('utf-8') # text -> bytes
198200

199201
### Raw Strings
200202

201-
String with uninterpreted backslash.
203+
Raw strings are strings with uninterpreted backslash. They are little by prefixing the initial quote with a lowercase "r".
202204

203205
```python
204206
>>> rs = r'c:\newdata\test' # Raw (uninterpreted backslash)
205207
>>> rs
206208
'c:\\newdata\\test'
207209
```
208210

209-
String is the literal text, exactly as typed.
211+
The string is the literal text, exactly as typed.
210212
This is useful in situations where the backslash has special significance. Example: filename, regular expressions, etc.
211213

212214
### f-Strings
213215

214-
String with formatted expression substitution.
216+
A string with formatted expression substitution.
215217

216218
```python
217219
>>> name = 'IBM'
@@ -226,9 +228,9 @@ String with formatted expression substitution.
226228
>>>
227229
```
228230

229-
**Note: Requires Python 3.6 or newer.**
231+
**Note: This requires Python 3.6 or newer.**
230232

231-
## Exercises 1.4
233+
## Exercises
232234

233235

234236
In this exercise, we experiment with operations on Python's string type.

Notes/01_Introduction/05_Lists.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22

33
This section introduces lists, one of Python's basic objects for storing collections of data.
44

5-
## Reading
6-
75
### Creating a List
86

97
Use square brackets to create a list:
@@ -156,7 +154,7 @@ s.sort() # ['bar', 'foo', 'spam']
156154
Specifically, lists don't represent vectors/matrices as in MATLAB, Octave, IDL, etc.
157155
However, there are some packages to help you with that (e.g. numpy).
158156

159-
## Exercises 1.5
157+
## Exercises
160158

161159
In this exercise, we experiment with Python's list datatype. In the last exercise, you worked with strings containing stock symbols.
162160

Notes/01_Introduction/06_Files.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22

33
This section discusses the basics of working with files.
44

5-
## Reading
6-
75
### File Input and Output
86

97
Open a file.
@@ -81,7 +79,7 @@ with open('outfile', 'wt') as f:
8179
...
8280
```
8381

84-
## Exercises 1.6
82+
## Exercises
8583

8684
This exercise depends on a file `Data/portfolio.csv`. The file contains a list of lines with information on a portfolio of stocks.
8785
Locate the file and look at its contents:
@@ -91,7 +89,7 @@ Locate the file and look at its contents:
9189
*Note: Make sure you are running Python in a location where you can access the `portfolio.csv` file.
9290
You can find out where Python thinks it's running by doing this:
9391

94-
```python
92+
```pycon
9593
>>> import os
9694
>>> os.getcwd()
9795
'/Users/beazley/Desktop/practical-python' # Output vary

Notes/01_Introduction/07_Functions.md

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
As your programs start to get larger, you'll want to get organized. This section
44
introduces functions. Error handling with exceptions is also introduced.
55

6-
## Reading
7-
86
### Custom Functions
97

108
Use functions for code you want to reuse. Here is a function definition:
@@ -100,8 +98,7 @@ Traceback (most recent call last):
10098
RuntimeError: What a kerfuffle
10199
```
102100

103-
104-
## Exercises 1.7
101+
## Exercises
105102

106103
### (a) Defining a function
107104

_layouts/default.html

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
<!DOCTYPE html>
2+
<html lang="{{ site.lang | default: "en-US" }}">
3+
<head>
4+
5+
{% if site.google_analytics %}
6+
<script async src="https://www.googletagmanager.com/gtag/js?id={{ site.google_analytics }}"></script>
7+
<script>
8+
window.dataLayer = window.dataLayer || [];
9+
function gtag(){dataLayer.push(arguments);}
10+
gtag('js', new Date());
11+
gtag('config', '{{ site.google_analytics }}');
12+
</script>
13+
{% endif %}
14+
<meta charset="UTF-8">
15+
16+
{% seo %}
17+
<meta name="viewport" content="width=device-width, initial-scale=1">
18+
<meta name="theme-color" content="#157878">
19+
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
20+
<link rel="stylesheet" href="{{ '/assets/css/style.css?v=' | append: site.github.build_revision | relative_url }}">
21+
</head>
22+
<body>
23+
<a id="skip-to-content" href="#content">Skip to the content.</a>
24+
25+
<header class="page-header" role="banner">
26+
<h1 class="project-name">Practical Python Programming</h1>
27+
<h2 class="project-tagline">A course by @dabeaz</h2>
28+
<!--{% if site.github.is_project_page %}
29+
<a href="{{ site.github.repository_url }}" class="btn">View on GitHub</a>
30+
{% endif %}
31+
-->
32+
{% if site.show_downloads %}
33+
<a href="{{ site.github.zip_url }}" class="btn">Download .zip</a>
34+
<a href="{{ site.github.tar_url }}" class="btn">Download .tar.gz</a>
35+
{% endif %}
36+
</header>
37+
38+
<main id="content" class="main-content" role="main">
39+
{{ content }}
40+
41+
<footer class="site-footer">
42+
{% if site.github.is_project_page %}
43+
<span class="site-footer-owner"><a href="{{ site.github.repository_url }}">{{ site.github.repository_name }}</a> is maintained by <a href="{{ site.github.owner_url }}">{{ site.github.owner_name }}</a>.</span>
44+
{% endif %}
45+
<span class="site-footer-credits">This page was generated by <a href="https://pages.github.com">GitHub Pages</a>.</span>
46+
</footer>
47+
</main>
48+
</body>
49+
</html>

0 commit comments

Comments
 (0)