Skip to content

Commit b976ac4

Browse files
authored
Merge pull request #220 from QuantEcon/fix-pbe_ex2
FIX: Fix Hint for Exercise 3.2
2 parents f5e1d20 + 35606cf commit b976ac4

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

lectures/python_by_example.md

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -521,10 +521,11 @@ Use a `for` loop to step through the $\alpha$ values.
521521
522522
If you can, add a legend, to help distinguish between the three time series.
523523
524-
Hints:
524+
```{hint}
525+
:class: dropdown
525526
526527
* If you call the `plot()` function multiple times before calling `show()`, all of the lines you produce will end up on the same figure.
527-
* For the legend, noted that the expression `'foo' + str(42)` evaluates to `'foo42'`.
528+
* For the legend, noted that suppose `var = 42`, the expression `f'foo{var}'` evaluates to `'foo42'`.
528529
```
529530

530531
```{exercise-end}
@@ -550,10 +551,11 @@ plt.legend()
550551
plt.show()
551552
```
552553

553-
Note: `f'$\\alpha = {α}$'` in the solution is an application of [f-String](https://docs.python.org/3/tutorial/inputoutput.html#tut-f-strings), which allows you to use `{}` to contain an expression.
554+
```{note}
555+
`f'$\\alpha = {α}$'` in the solution is an application of [f-String](https://docs.python.org/3/tutorial/inputoutput.html#tut-f-strings), which allows you to use `{}` to contain an expression.
554556
555557
The contained expression will be evaluated, and the result will be placed into the string.
556-
558+
```
557559

558560
```{solution-end}
559561
```
@@ -692,11 +694,15 @@ Use no imports besides
692694
import numpy as np
693695
```
694696

697+
```{hint}
698+
:class: dropdown
699+
695700
Your hints are as follows:
696701
697702
* If $U$ is a bivariate uniform random variable on the unit square $(0, 1)^2$, then the probability that $U$ lies in a subset $B$ of $(0,1)^2$ is equal to the area of $B$.
698703
* If $U_1,\ldots,U_n$ are IID copies of $U$, then, as $n$ gets large, the fraction that falls in $B$, converges to the probability of landing in $B$.
699704
* For a circle, $area = \pi * radius^2$.
705+
```
700706

701707
```{exercise-end}
702708
```

0 commit comments

Comments
 (0)