Skip to content

Commit 9fc25a7

Browse files
committed
feat: hide solutions
1 parent eb4fde7 commit 9fc25a7

7 files changed

Lines changed: 176 additions & 31 deletions

File tree

Course1/slides.qmd

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ format:
1111
chalkboard: true
1212
logo: https://www.hevs.ch/_nuxt/img/logo_hesso.9af1d79.svg
1313
footer: "Python Basics & Objects"
14+
include-in-header: ../_includes/revealscript.html
1415

1516
execute:
1617
echo: true # ← this shows code
@@ -404,20 +405,27 @@ Write a Python program that:
404405

405406
3. Uses if statements to check answers (use object method to make it UPPER or lower case and then compare to the right answer)
406407

408+
---
409+
407410
4. Uses a for or while loop to ask questions one by one (and `input()` + `print()`)
408411

409412
5. Keeps track of the score using a variable and `if-else` statements to increment the score.
410413

411414
6. Prints the final score and a custom message
412415

413-
## More references
416+
## More references
414417

415418
[Python course for data analysis](https://github.com/jbossios/python-tutorial/tree/c2db1696439b23c0e4c02eff680bf61e45caab7e?tab=readme-ov-file)
416419

417420
[The Python tutorial](https://docs.python.org/3/tutorial/)
418421

419422
## Solution
420423

424+
<div class="reveal-solution-container" style="margin-top: 1em;">
425+
<button onclick="revealSolution(this)" data-code="cheater">Show Solution</button>
426+
<input type="text" class="solution-code" placeholder="Enter code" />
427+
<div class="solution-content" style="display: none; margin-top: 0.5em;">
428+
421429
```{pyodide}
422430
print("Welcome to the Python Quiz!")
423431
@@ -455,5 +463,6 @@ else:
455463
print("Keep practicing!")
456464
```
457465

458-
466+
</div>
467+
</div>
459468

Course2/slides.qmd

Lines changed: 31 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ format:
1111
chalkboard: true
1212
logo: https://www.hevs.ch/_nuxt/img/logo_hesso.9af1d79.svg
1313
footer: "Functions, Lists, Dictionaries & Classes"
14+
include-in-header: ../_includes/revealscript.html
1415

1516
execute:
1617
echo: true # ← this shows code
@@ -512,6 +513,11 @@ Define student data: Create a list of students. Each student is a dictionary con
512513

513514
### Solution
514515

516+
<div class="reveal-solution-container" style="margin-top: 1em;">
517+
<button onclick="revealSolution(this)" data-code="cheater">Show Solution</button>
518+
<input type="text" class="solution-code" placeholder="Enter code" />
519+
<div class="solution-content" style="display: none; margin-top: 0.5em;">
520+
515521
```{pyodide}
516522
students = [
517523
{
@@ -527,6 +533,9 @@ students = [
527533
]
528534
```
529535

536+
</div>
537+
</div>
538+
530539
---
531540

532541
Write functions, taking your list of students, to:
@@ -539,6 +548,11 @@ Write functions, taking your list of students, to:
539548

540549
### Solution
541550

551+
<div class="reveal-solution-container" style="margin-top: 1em;">
552+
<button onclick="revealSolution(this)" data-code="cheater">Show Solution</button>
553+
<input type="text" class="solution-code" placeholder="Enter code" />
554+
<div class="solution-content" style="display: none; margin-top: 0.5em;">
555+
542556
```{pyodide}
543557
def get_all_names(students):
544558
return [student["name"] for student in students]
@@ -552,6 +566,9 @@ print(get_all_names(students=students))
552566
print(calculate_average(students[0]["grades"]))
553567
554568
```
569+
</div>
570+
</div>
571+
555572
---
556573

557574
### Create a Student class
@@ -564,13 +581,14 @@ Define a class with attributes: name, age, grades, and methods to:
564581

565582
- Display infos (whatever you want to print)
566583

567-
## More references
568584

569-
[Python course for data analysis](https://github.com/jbossios/python-tutorial/tree/c2db1696439b23c0e4c02eff680bf61e45caab7e?tab=readme-ov-file)
585+
## Solution
570586

571-
[The Python tutorial](https://docs.python.org/3/tutorial/)
587+
<div class="reveal-solution-container" style="margin-top: 1em;">
588+
<button onclick="revealSolution(this)" data-code="cheater">Show Solution</button>
589+
<input type="text" class="solution-code" placeholder="Enter code" />
590+
<div class="solution-content" style="display: none; margin-top: 0.5em;">
572591

573-
## Solution
574592
```{pyodide}
575593
class Student:
576594
def __init__(self, name, age, grades=None):
@@ -593,4 +611,12 @@ student.add_grade("sport", 85)
593611
594612
print(student.infos())
595613
596-
```
614+
```
615+
</div>
616+
</div>
617+
618+
## More references
619+
620+
[Python course for data analysis](https://github.com/jbossios/python-tutorial/tree/c2db1696439b23c0e4c02eff680bf61e45caab7e?tab=readme-ov-file)
621+
622+
[The Python tutorial](https://docs.python.org/3/tutorial/)

Course3/slides.qmd

Lines changed: 31 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ format:
1111
chalkboard: true
1212
logo: https://www.hevs.ch/_nuxt/img/logo_hesso.9af1d79.svg
1313
footer: "Files, Data & Practice"
14+
include-in-header: ../_includes/revealscript.html
1415

1516
execute:
1617
echo: true # ← this shows code
@@ -158,13 +159,13 @@ Objectives:
158159
- Open and parse the JSON file using `json.load()`
159160
- Check structure: list of colonies, each with conditions + growth
160161

161-
## More references
162-
163-
[Python course for data analysis](https://github.com/jbossios/python-tutorial/tree/c2db1696439b23c0e4c02eff680bf61e45caab7e?tab=readme-ov-file)
162+
## Solution
164163

165-
[The Python tutorial](https://docs.python.org/3/tutorial/)
164+
<div class="reveal-solution-container" style="margin-top: 1em;">
165+
<button onclick="revealSolution(this)" data-code="cheater">Show Solution</button>
166+
<input type="text" class="solution-code" placeholder="Enter code" />
167+
<div class="solution-content" style="display: none; margin-top: 0.5em;">
166168

167-
## Solution
168169
```python
169170
import json
170171

@@ -173,6 +174,8 @@ with open("colonies.json", "r") as f:
173174

174175
print(data[0].keys())
175176
```
177+
</div>
178+
</div>
176179

177180
## Step 2: Define a Colonie
178181

@@ -186,16 +189,21 @@ Method
186189
- `math` package for exp, log functions
187190

188191
Using formula:
189-
190-
```latex
192+
$$
191193
G(t) = S \cdot e^{-\frac{(T - 37)^2}{20}} \cdot \left(1 - 0.3 \cdot \left| \text{pH} - 7 \right| \right) \cdot \ln(t + 1)
192-
```
194+
$$
195+
196+
$S$: Sugar, $T$: temperature, $pH$: pH level, $t$: time (h)
193197

194-
S: Sugar, T: temperature, pH: pH level, t: time (h)
195198
---
196199

197200
### Solution
198201

202+
<div class="reveal-solution-container" style="margin-top: 1em;">
203+
<button onclick="revealSolution(this)" data-code="cheater">Show Solution</button>
204+
<input type="text" class="solution-code" placeholder="Enter code" />
205+
<div class="solution-content" style="display: none; margin-top: 0.5em;">
206+
199207
```python
200208
import math
201209

@@ -211,6 +219,8 @@ class Colonie:
211219
ph_factor = 1 - abs(self.ph - 7) * 0.3
212220
return round(base * ph_factor * math.log(t + 1), 3)
213221
```
222+
</div>
223+
</div>
214224

215225
## Step 3: Create Objects and Compare Predictions
216226

@@ -219,9 +229,13 @@ class Colonie:
219229
- Predict growth at fixed times (e.g. 3, 5, 8)
220230
- Compare with actual values in the dataset
221231

222-
---
223232

224-
### Solution
233+
## Solution
234+
235+
<div class="reveal-solution-container" style="margin-top: 1em;">
236+
<button onclick="revealSolution(this)" data-code="cheater">Show Solution</button>
237+
<input type="text" class="solution-code" placeholder="Enter code" />
238+
<div class="solution-content" style="display: none; margin-top: 0.5em;">
225239

226240
```python
227241
fixed_times = [3, 5, 8]
@@ -236,8 +250,14 @@ for item in data:
236250
predicted = c.predict_growth(t)
237251
print(f" t={t}h: predicted={predicted}, actual={actual}")
238252
```
253+
</div>
254+
</div>
255+
256+
## More references
239257

258+
[Python course for data analysis](https://github.com/jbossios/python-tutorial/tree/c2db1696439b23c0e4c02eff680bf61e45caab7e?tab=readme-ov-file)
240259

260+
[The Python tutorial](https://docs.python.org/3/tutorial/)
241261

242262

243263

Course4/slides.qmd

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ format:
1111
chalkboard: true
1212
logo: https://www.hevs.ch/_nuxt/img/logo_hesso.9af1d79.svg
1313
footer: "Numpy"
14+
include-in-header: ../_includes/revealscript.html
1415

1516
execute:
1617
echo: true # ← this shows code
@@ -443,14 +444,15 @@ You're working with sensor data collected in a lab: each row represents a differ
443444
4. Subtract mean from each row (sensor), using broadcasting
444445
5. Simulate a new column of sensor (i.e. use `randint` with correct shape) readings and concatenate it to the existing data.
445446

446-
## More references
447-
448-
[Python course for data analysis](https://github.com/jbossios/python-tutorial/tree/c2db1696439b23c0e4c02eff680bf61e45caab7e?tab=readme-ov-file)
449447

450-
[Numpy](https://numpy.org/doc/stable/user/quickstart.html)
451448

452449
## Solution
453450

451+
<div class="reveal-solution-container" style="margin-top: 1em;">
452+
<button onclick="revealSolution(this)" data-code="cheater">Show Solution</button>
453+
<input type="text" class="solution-code" placeholder="Enter code" />
454+
<div class="solution-content" style="display: none; margin-top: 0.5em;">
455+
454456
```{pyodide}
455457
456458
import numpy as np
@@ -492,3 +494,12 @@ data = np.concatenate((data, new_timepoint), axis=1)
492494
print("-----------------")
493495
494496
```
497+
498+
</div>
499+
</div>
500+
501+
## More references
502+
503+
[Python course for data analysis](https://github.com/jbossios/python-tutorial/tree/c2db1696439b23c0e4c02eff680bf61e45caab7e?tab=readme-ov-file)
504+
505+
[Numpy](https://numpy.org/doc/stable/user/quickstart.html)

0 commit comments

Comments
 (0)