Skip to content

Commit aae892e

Browse files
committed
feat: add course + small modif in previous courses
1 parent 0f1a371 commit aae892e

File tree

6 files changed

+523
-1
lines changed

6 files changed

+523
-1
lines changed

Course1/exercise.py

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
2+
print("Welcome to the Python Quiz!")
3+
4+
name = input("What's your name? ")
5+
print("Hi", name + "!", "Let's begin.\n")
6+
7+
score = 0
8+
9+
questions = [
10+
"What is 2 + 2?",
11+
"What is the capital of France?",
12+
"What returns \"python\".upper() do in Python?"
13+
]
14+
15+
answers = [
16+
"4",
17+
"paris",
18+
"PYTHON"
19+
]
20+
21+
for i, q in enumerate(questions):
22+
answer = input(q + " ").lower()
23+
if answers[i].lower() == answer.lower():
24+
print("✅ Correct!\n")
25+
score += 1
26+
else:
27+
print("❌ Wrong!\n")
28+
29+
print("You got", score, "out of", len(questions))
30+
if score == 3:
31+
print("Perfect score! Great job,", name.upper() + "!")
32+
elif score > 0:
33+
print("Not bad! Try again to improve.")
34+
else:
35+
print("Keep practicing!")

Course2/slides.qmd

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -567,7 +567,6 @@ Define a class with attributes: name, age, grades, and methods to:
567567
---
568568

569569
### Solution
570-
571570
```{pyodide}
572571
class Student:
573572
def __init__(self, name, age, grades=None):

Course3/colonies.json

Lines changed: 202 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,202 @@
1+
[
2+
{
3+
"name": "Colony_0",
4+
"conditions": {
5+
"temperature": 42,
6+
"ph": 8.0,
7+
"sugar": 1.13
8+
},
9+
"growth": {
10+
"0": 0.0,
11+
"1": 0.157,
12+
"2": 0.249,
13+
"3": 0.314,
14+
"4": 0.365,
15+
"5": 0.406,
16+
"6": 0.441,
17+
"7": 0.471,
18+
"8": 0.498,
19+
"9": 0.522
20+
}
21+
},
22+
{
23+
"name": "Colony_1",
24+
"conditions": {
25+
"temperature": 30,
26+
"ph": 6.0,
27+
"sugar": 1.55
28+
},
29+
"growth": {
30+
"0": 0.0,
31+
"1": 0.065,
32+
"2": 0.103,
33+
"3": 0.13,
34+
"4": 0.151,
35+
"5": 0.168,
36+
"6": 0.182,
37+
"7": 0.195,
38+
"8": 0.206,
39+
"9": 0.216
40+
}
41+
},
42+
{
43+
"name": "Colony_2",
44+
"conditions": {
45+
"temperature": 42,
46+
"ph": 7.0,
47+
"sugar": 2.0
48+
},
49+
"growth": {
50+
"0": 0.0,
51+
"1": 0.397,
52+
"2": 0.63,
53+
"3": 0.794,
54+
"4": 0.922,
55+
"5": 1.027,
56+
"6": 1.115,
57+
"7": 1.192,
58+
"8": 1.259,
59+
"9": 1.319
60+
}
61+
},
62+
{
63+
"name": "Colony_3",
64+
"conditions": {
65+
"temperature": 30,
66+
"ph": 8.0,
67+
"sugar": 1.51
68+
},
69+
"growth": {
70+
"0": 0.0,
71+
"1": 0.063,
72+
"2": 0.1,
73+
"3": 0.126,
74+
"4": 0.147,
75+
"5": 0.163,
76+
"6": 0.177,
77+
"7": 0.19,
78+
"8": 0.2,
79+
"9": 0.21
80+
}
81+
},
82+
{
83+
"name": "Colony_4",
84+
"conditions": {
85+
"temperature": 30,
86+
"ph": 6.0,
87+
"sugar": 1.79
88+
},
89+
"growth": {
90+
"0": 0.0,
91+
"1": 0.075,
92+
"2": 0.119,
93+
"3": 0.15,
94+
"4": 0.174,
95+
"5": 0.194,
96+
"6": 0.21,
97+
"7": 0.225,
98+
"8": 0.238,
99+
"9": 0.249
100+
}
101+
},
102+
{
103+
"name": "Colony_5",
104+
"conditions": {
105+
"temperature": 37,
106+
"ph": 8.0,
107+
"sugar": 1.71
108+
},
109+
"growth": {
110+
"0": 0.0,
111+
"1": 0.83,
112+
"2": 1.315,
113+
"3": 1.659,
114+
"4": 1.926,
115+
"5": 2.145,
116+
"6": 2.329,
117+
"7": 2.489,
118+
"8": 2.63,
119+
"9": 2.756
120+
}
121+
},
122+
{
123+
"name": "Colony_6",
124+
"conditions": {
125+
"temperature": 42,
126+
"ph": 6.0,
127+
"sugar": 1.7
128+
},
129+
"growth": {
130+
"0": 0.0,
131+
"1": 0.236,
132+
"2": 0.375,
133+
"3": 0.473,
134+
"4": 0.549,
135+
"5": 0.611,
136+
"6": 0.663,
137+
"7": 0.709,
138+
"8": 0.749,
139+
"9": 0.785
140+
}
141+
},
142+
{
143+
"name": "Colony_7",
144+
"conditions": {
145+
"temperature": 37,
146+
"ph": 7.0,
147+
"sugar": 0.98
148+
},
149+
"growth": {
150+
"0": 0.0,
151+
"1": 0.679,
152+
"2": 1.077,
153+
"3": 1.359,
154+
"4": 1.577,
155+
"5": 1.756,
156+
"6": 1.907,
157+
"7": 2.038,
158+
"8": 2.153,
159+
"9": 2.257
160+
}
161+
},
162+
{
163+
"name": "Colony_8",
164+
"conditions": {
165+
"temperature": 42,
166+
"ph": 6.0,
167+
"sugar": 1.17
168+
},
169+
"growth": {
170+
"0": 0.0,
171+
"1": 0.163,
172+
"2": 0.258,
173+
"3": 0.325,
174+
"4": 0.378,
175+
"5": 0.42,
176+
"6": 0.457,
177+
"7": 0.488,
178+
"8": 0.516,
179+
"9": 0.54
180+
}
181+
},
182+
{
183+
"name": "Colony_9",
184+
"conditions": {
185+
"temperature": 37,
186+
"ph": 7.0,
187+
"sugar": 1.2
188+
},
189+
"growth": {
190+
"0": 0.0,
191+
"1": 0.832,
192+
"2": 1.318,
193+
"3": 1.664,
194+
"4": 1.931,
195+
"5": 2.15,
196+
"6": 2.335,
197+
"7": 2.495,
198+
"8": 2.637,
199+
"9": 2.763
200+
}
201+
}
202+
]

Course3/generate_data.py

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
import json
2+
import random
3+
import math
4+
from typing import List, Dict
5+
6+
# Step 1: Generate synthetic bacterial colony data
7+
def generate_colony_data(n=10, times=range(0, 10)):
8+
colonies = []
9+
for i in range(n):
10+
name = f"Colony_{i}"
11+
temperature = random.choice([30, 37, 42]) # degrees Celsius
12+
ph = random.choice([6.0, 7.0, 8.0])
13+
sugar = round(random.uniform(0.5, 2.0), 2) # glucose concentration (g/L)
14+
15+
# Use an arbitrary growth formula to generate data
16+
growth_data = {}
17+
for t in times:
18+
base = sugar * math.exp(-((temperature - 37) ** 2) / 20) # peak at 37°C
19+
ph_factor = 1 - abs(ph - 7) * 0.3 # best growth at pH 7
20+
growth = base * ph_factor * math.log(t + 1) # log growth over time
21+
growth_data[str(t)] = round(growth, 3)
22+
23+
colony = {
24+
"name": name,
25+
"conditions": {
26+
"temperature": temperature,
27+
"ph": ph,
28+
"sugar": sugar
29+
},
30+
"growth": growth_data
31+
}
32+
colonies.append(colony)
33+
34+
return colonies
35+
36+
# Generate and save the dataset
37+
colony_dataset = generate_colony_data(n=10, times=range(0, 10))
38+
39+
with open("colonies.json", "w") as f:
40+
json.dump(colony_dataset, f, indent=2)

Course3/index.qmd

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Week title
2+
3+
[👨🏻‍🏫 Slides]({{< var base_url>}}slides/Course3/slides.html){.btn .btn-outline-primary .btn role="button"}
4+
[Slides PDF]({{< var base_url>}}slides/Course3/slides.pdf){.btn .btn-outline-secondary .btn role="button"}

0 commit comments

Comments
 (0)