Skip to content

Commit ff85709

Browse files
committed
ch01
1 parent 028f699 commit ff85709

File tree

19 files changed

+161
-0
lines changed

19 files changed

+161
-0
lines changed

ch01/README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
Chapter 1 data files
2+
====================
3+
4+
The files in this folder are not supposed to work if run.
5+
They serve as source for the book chapters, and to provide a
6+
quick copy/paste tool for whoever would need their content.

ch01/bike.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# let's define the class Bike
2+
class Bike:
3+
4+
def __init__(self, colour, frame_material):
5+
self.colour = colour
6+
self.frame_material = frame_material
7+
8+
def brake(self):
9+
print("Braking!")
10+
11+
# let's create a couple of instances
12+
red_bike = Bike('Red', 'Carbon fiber')
13+
blue_bike = Bike('Blue', 'Steel')
14+
15+
# let's inspect the objects we have, instances of the Bike class.
16+
print(red_bike.colour) # prints: Red
17+
print(red_bike.frame_material) # prints: Carbon fiber
18+
print(blue_bike.colour) # prints: Blue
19+
print(blue_bike.frame_material) # prints: Steel
20+
21+
# let's brake!
22+
red_bike.brake() # prints: Braking!

ch01/example/core.py

Whitespace-only changes.

ch01/example/run.py

Whitespace-only changes.

ch01/example/util/__init__.py

Whitespace-only changes.

ch01/example/util/db.py

Whitespace-only changes.

ch01/example/util/math.py

Whitespace-only changes.

ch01/example/util/network.py

Whitespace-only changes.

ch01/factorial.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
>>> from math import factorial
2+
>>> factorial(5)
3+
120

ch01/files_only/core.py

Whitespace-only changes.

0 commit comments

Comments
 (0)