Skip to content

Commit a78058e

Browse files
committed
adding hint and note admonitions
1 parent 2a42468 commit a78058e

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

lectures/python_by_example.md

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -521,13 +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.
527528
* For the legend, noted that if `var = 42`, the expression `f'foo{var}'` evaluates to `'foo42'`.
528-
529-
Note: `f'foo{var}'` is an example of [f-String](https://docs.python.org/3/tutorial/inputoutput.html#tut-f-strings), which allows you to use `{}` to contain an expression. The contained expression will be evaluated, and the result will be placed into the string.
530-
531529
```
532530

533531
```{exercise-end}
@@ -553,6 +551,12 @@ plt.legend()
553551
plt.show()
554552
```
555553

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.
556+
557+
The contained expression will be evaluated, and the result will be placed into the string.
558+
```
559+
556560
```{solution-end}
557561
```
558562

@@ -690,11 +694,15 @@ Use no imports besides
690694
import numpy as np
691695
```
692696

697+
```{hint}
698+
:class: dropdown
699+
693700
Your hints are as follows:
694701
695702
* 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$.
696703
* 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$.
697704
* For a circle, $area = \pi * radius^2$.
705+
```
698706

699707
```{exercise-end}
700708
```

0 commit comments

Comments
 (0)