Skip to content

Commit cf78467

Browse files
committed
Added markdown syntax highlighting to lesson
1 parent 6f19b9e commit cf78467

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

README.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ For this lesson you'll need to have _Python 2.7_ installed. If you're on Mac or
1010

1111
Let's jump right into some code. Create a new Python file called `binary_example1.py`. Type this into it:
1212

13-
```
13+
```py
1414
num = 1
1515
print num
1616

@@ -21,7 +21,7 @@ for i in range(11):
2121

2222
Run it, and you'll see that this is what you get:
2323

24-
```
24+
```sh
2525
$ python binary_example1.py
2626
1
2727
2
@@ -80,7 +80,7 @@ So that is the basics of how transistors came to be used in computer hardware. H
8080

8181
Let's look at `binary_example1.py` again.
8282

83-
```
83+
```py
8484
num = 1
8585
print num
8686

@@ -99,7 +99,7 @@ The **left shift operator** (`<<`) takes the binary version of the number to the
9999

100100
So throughout our program, the variable `num` is backed by these values:
101101

102-
```
102+
```py
103103
00000001 # num = 1
104104
00000010 # num = num << 1
105105
00000100 # num = num << 1
@@ -112,7 +112,7 @@ So throughout our program, the variable `num` is backed by these values:
112112

113113
See how the `1` bit shifts to the left with every cycle of the `for` loop? We can map these **octets** to our program output to see how they match up.
114114

115-
```
115+
```py
116116
00000001 # 1
117117
00000010 # 2
118118
00000100 # 4
@@ -126,7 +126,7 @@ See how the `1` bit shifts to the left with every cycle of the `for` loop? We ca
126126

127127
What about `256`, `512`, `1024` and `2048`? Python knows that it needs another **byte** to store those larger numbers, so we get another **octet** to left shift into.
128128

129-
```
129+
```py
130130
00000000 00000001 # 1
131131
00000000 00000010 # 2
132132
00000000 00000100 # 4
@@ -147,7 +147,7 @@ Now we need to understand why the position of the `1` bit determines which numbe
147147

148148
Let's make a new Python file and call it `binary_example2.py`. It's going to be a lot like our first example, but we are going to replace the **left shift** with another expression.
149149

150-
```
150+
```py
151151
num = 1
152152
print num
153153

@@ -158,7 +158,7 @@ for i in range(11):
158158

159159
**What do you think this program outputs?** Here's a hint: remember how after we played the _2048_ game I said to think about the numbers as `2 * 2`, `2 * 4`, `2 * 8`, and so on? Lo and behold!
160160

161-
```
161+
```sh
162162
$ python binary_example2.py
163163
1
164164
2
@@ -233,7 +233,7 @@ So letters on a computer are just an illusion! At least an illusion as far as th
233233
Here's our last example, `binary_example3.py`. I am using the `ord()` and `chr()` functions to find the number value for a character, messing with that
234234
number, then turning it back into a character.
235235
236-
```
236+
```py
237237
letter_a = "A"
238238
letters = []
239239

0 commit comments

Comments
 (0)