Skip to content
This repository was archived by the owner on Jun 27, 2026. It is now read-only.

Commit f98e99b

Browse files
committed
Edit
1 parent 4ea53cb commit f98e99b

3 files changed

Lines changed: 21 additions & 56 deletions

File tree

Notes/01_Introduction/01_Python.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ shell. This is Python's native environment. If you are able to use
5959
Python in the shell, you will be able to use virtually everywhere
6060
else.
6161

62-
## Exercises 1.1
62+
## Exercises
6363

6464
### (a) Using Python as a Calculator
6565

Notes/01_Introduction/02_Hello_world.md

Lines changed: 18 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -194,11 +194,10 @@ Comments are denoted by `#` and extend to the end of the line.
194194

195195
### Variables
196196

197-
A variable is a name for a value.
198-
199-
You can use letters (lower and upper-case) from a to z. As well as the character underscore `_`.
200-
201-
Numbers can also be part of the name of a variable, except as the first character.
197+
A variable is a name for a value. You can use letters (lower and
198+
upper-case) from a to z. As well as the character underscore `_`.
199+
Numbers can also be part of the name of a variable, except as the
200+
first character.
202201

203202
```python
204203
height = 442 # valid
@@ -221,7 +220,6 @@ height = 'Really tall' # A string
221220
### Case Sensitivity
222221

223222
Python is case sensitive. Upper and lower-case letters are considered different letters.
224-
225223
These are all different variables:
226224

227225
```python
@@ -240,7 +238,6 @@ WHILE x < 0: # ERROR
240238
### Looping
241239

242240
Looping is a way to execute a set of instructions any number of times.
243-
244241
There are many ways to accomplish this in Python, one of them is the `while` statement:
245242

246243
```python
@@ -257,7 +254,6 @@ The statements below the `while` will execute as long as the expression after th
257254
### Indentation
258255

259256
Indentation in Python is used to denote a set of statements that go together.
260-
261257
From our previous example:
262258

263259
```python
@@ -277,25 +273,15 @@ The indentation means that the following statements go together under the `while
277273
num_bills = num_bills * 2
278274
```
279275

280-
Because the next statement is not indented, it means that it does not belong to the previous set.
281-
282-
```python
283-
print('Number of days', days)
284-
```
285-
286-
The empty line is just for readability. It does not affect the execution.
287-
288-
### Blocks
289-
290-
A block is a set of statements grouped together.
276+
Because the next statement is not indented, it means that it does not
277+
belong to the previous set. The empty line is just for
278+
readability. It does not affect the execution.
291279

292-
In our previous example, the statements within the `while` form a *block*.
280+
### Indentation best practices
293281

294-
```python
295-
print(day, num_bills, num_bills * bill_thickness)
296-
day = day + 1
297-
num_bills = num_bills * 2
298-
```
282+
* Use spaces instead of tabs.
283+
* Use 4 spaces per level.
284+
* Use a Python-aware editor.
299285

300286
Indentation within the block must be consistent.
301287

@@ -306,28 +292,17 @@ while num_bills * bill_thickness < sears_height:
306292
num_bills = num_bills * 2
307293
```
308294

309-
The character colon `:` indicates the start of a block and must be present.
310-
311-
```python
312-
while num_bills * bill_thickness < sears_height:
313-
```
314-
315-
### Indentation best practices
316-
317-
* Use spaces instead of tabs.
318-
* Use 4 spaces per level.
319-
* Use a Python-aware editor.
320295

321296
### Conditionals
322297

323298
The `if` statement is used to execute a conditional:
324299

325300
```python
326301
if a > b:
327-
# `a` is greater than `b`
302+
# a is greater than b
328303
print('Computer says no')
329304
else:
330-
# `a` is lower or equal to `b`
305+
# a is lower or equal to b
331306
print('Computer says yes')
332307
```
333308

@@ -337,13 +312,13 @@ You can check for multiple conditions with the `elif`.
337312

338313
```python
339314
if a > b:
340-
# `a` is greater than `b`
315+
# a is greater than b
341316
print('Computer says no')
342317
elif a == b:
343-
# `a` is equal to `b`
318+
# a is equal to b
344319
print('Computer says yes')
345320
else:
346-
# `a` is lower to `b`
321+
# a is lower to b
347322
print('Computer says maybe')
348323
```
349324

@@ -406,16 +381,12 @@ print('Your name is', name)
406381
```
407382

408383
`input` prints a prompt to the user and returns the response.
409-
410384
This is useful for small programs, learning exercises or simple debugging.
411-
412385
It is not widely used for real programs.
413386

414387
### `pass` statement
415388

416-
Sometimes you need to specify an empty block.
417-
418-
The keyword `pass` is used for it.
389+
Sometimes you need to specify an empty block. The keyword `pass` is used for it.
419390

420391
```python
421392
if a > b:
@@ -426,7 +397,7 @@ else:
426397

427398
This is also called a "no-op" statement. It does nothing. It serves as a placeholder for statements. Possibly to be added later.
428399

429-
## Exercises 1.2
400+
## Exercises
430401

431402
### (a) The Bouncing Ball
432403

Notes/01_Introduction/03_Numbers.md

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

33
This section covers some basics of performing mathematical calculations in Python.
44

5-
## Reading
6-
75
### Types of Numbers
86

97
Python has 4 types of numbers:
@@ -95,12 +93,11 @@ c = -1.345e-10
9593
```
9694

9795
Floats are represented as double precision using the native CPU representation [IEEE 754](https://en.wikipedia.org/wiki/IEEE_754).
96+
This is the same as the `double` type in the programming language C.
9897

9998
> 17 digits or precision
10099
> Exponent from -308 to 308
101100
102-
This is the same as the `double` type in the programming language C.
103-
104101
Be aware that floating point numbers are inexact when representing decimals.
105102

106103
```python
@@ -128,7 +125,6 @@ abs(x) Absolute Value
128125
```
129126

130127
Theses are the same operators as Integers, except for the bit-wise operators.
131-
132128
Additional math functions are found in the `math` module.
133129

134130
```python
@@ -161,7 +157,7 @@ Try it out.
161157
>>>
162158
```
163159

164-
## Exercise 1.3
160+
## Exercises
165161

166162
### (a) Dave's mortgage
167163

@@ -198,7 +194,6 @@ When you run the new program, it should report a total payment of `929,965.62` o
198194
### (c) Making an Extra Payment Calculator
199195

200196
Modify the program so that extra payment information can be more generally handled.
201-
202197
Make it so that the user can set these variables:
203198

204199
```python
@@ -214,7 +209,6 @@ How much will Dave pay if he pays an extra $1000/month for 4 years starting in y
214209
### (d) Making a table
215210

216211
Modify the program to print out a table showing the month, total paid so far, and the remaining principal.
217-
218212
The output should look something like this:
219213

220214
```bash

0 commit comments

Comments
 (0)