Skip to content

Commit 4837564

Browse files
authored
Merge pull request #681 from danny-lloyd/improve-formatting-ep16
Improve formatting of episode 16 solution
2 parents f52a5f1 + fe0fb11 commit 4837564

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

episodes/16-writing-functions.md

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -573,21 +573,25 @@ density. In the model, time takes discrete values 0, 1, 2, ...
573573

574574
## Solution
575575

576-
1. ```python
576+
1.
577+
```python
577578
def logistic_map(x, r):
578579
return r * x * (1 - x)
579580
```
580581

581-
2. ```python
582+
2.
583+
```python
582584
initial_population = 0.5
583585
t_final = 10
584586
r = 1.0
585587
population = [initial_population]
588+
586589
for t in range(t_final):
587590
population.append( logistic_map(population[t], r) )
588591
```
589592

590-
3. ```python
593+
3.
594+
```python
591595
def iterate(initial_population, t_final, r):
592596
population = [initial_population]
593597
for t in range(t_final):
@@ -598,7 +602,7 @@ density. In the model, time takes discrete values 0, 1, 2, ...
598602
population = iterate(0.5, period, 1)
599603
print(population[-1])
600604
```
601-
605+
602606
```output
603607
0.06945089389714401
604608
0.009395779870614648

0 commit comments

Comments
 (0)