Skip to content

Commit bfebc36

Browse files
committed
Starter code and info for ai coding chapter.
1 parent 613441d commit bfebc36

File tree

3 files changed

+165
-0
lines changed

3 files changed

+165
-0
lines changed
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Video Game Data
2+
3+
We are using video game sales data challenge from Kaggle. They have a great CSV with structured data.
4+
5+
Please download it from:
6+
7+
https://www.kaggle.com/datasets/gregorut/videogamesales
8+
9+
(see "Download" button in the upper right)
Lines changed: 142 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,142 @@
1+
{
2+
"cells": [
3+
{
4+
"cell_type": "markdown",
5+
"id": "a7f21c6dae76f057",
6+
"metadata": {},
7+
"source": [
8+
"# Organizing Code\n",
9+
"\n",
10+
"The idea of this notebook is to leverage the complex but not exactly relevant code found in `mathf`, our math utility library."
11+
]
12+
},
13+
{
14+
"cell_type": "code",
15+
"execution_count": 1,
16+
"id": "6040bded7e982e0c",
17+
"metadata": {
18+
"ExecuteTime": {
19+
"end_time": "2025-07-26T17:50:06.856743Z",
20+
"start_time": "2025-07-26T17:50:06.852198Z"
21+
},
22+
"jupyter": {
23+
"source_hidden": true
24+
}
25+
},
26+
"outputs": [],
27+
"source": [
28+
"# Import our math functions.\n",
29+
"import mathf"
30+
]
31+
},
32+
{
33+
"cell_type": "markdown",
34+
"id": "9209940ceb5e46c0",
35+
"metadata": {},
36+
"source": [
37+
"## Primes and Fibonacci?\n",
38+
"\n",
39+
"Let's see if there is a relationship between primes and fibonacci numbers."
40+
]
41+
},
42+
{
43+
"cell_type": "code",
44+
"execution_count": 2,
45+
"id": "c8beeefbe98fd1b8",
46+
"metadata": {
47+
"ExecuteTime": {
48+
"end_time": "2025-07-26T17:50:08.846973Z",
49+
"start_time": "2025-07-26T17:50:08.843648Z"
50+
}
51+
},
52+
"outputs": [],
53+
"source": [
54+
"prime = 17\n",
55+
"all_fibs = mathf.fibonacci()\n",
56+
"based_fibs = mathf.multiples_of(all_fibs, prime)\n",
57+
"\n",
58+
"first_10 = []\n",
59+
"for idx, fib in enumerate(based_fibs):\n",
60+
" first_10.append(fib)\n",
61+
" if idx > 10:\n",
62+
" break"
63+
]
64+
},
65+
{
66+
"cell_type": "markdown",
67+
"id": "ca9ad6fe20a217d7",
68+
"metadata": {},
69+
"source": [
70+
"What are the first 10 which are multiples of 17?"
71+
]
72+
},
73+
{
74+
"cell_type": "code",
75+
"execution_count": 3,
76+
"id": "980daf7b8a4f2a61",
77+
"metadata": {
78+
"ExecuteTime": {
79+
"end_time": "2025-07-26T17:52:08.542715Z",
80+
"start_time": "2025-07-26T17:52:08.540403Z"
81+
},
82+
"jupyter": {
83+
"source_hidden": true
84+
}
85+
},
86+
"outputs": [
87+
{
88+
"name": "stdout",
89+
"output_type": "stream",
90+
"text": [
91+
"34\n",
92+
"2,584\n",
93+
"196,418\n",
94+
"14,930,352\n",
95+
"1,134,903,170\n",
96+
"86,267,571,272\n",
97+
"6,557,470,319,842\n",
98+
"498,454,011,879,264\n",
99+
"37,889,062,373,143,906\n",
100+
"2,880,067,194,370,816,120\n",
101+
"218,922,995,834,555,169,026\n",
102+
"16,641,027,750,620,563,662,096\n"
103+
]
104+
}
105+
],
106+
"source": [
107+
"numbers_text = [f'{tn:,}' for tn in first_10]\n",
108+
"for n in numbers_text:\n",
109+
" print(n)"
110+
]
111+
},
112+
{
113+
"cell_type": "code",
114+
"execution_count": null,
115+
"id": "b2c870122e665de2",
116+
"metadata": {},
117+
"outputs": [],
118+
"source": []
119+
}
120+
],
121+
"metadata": {
122+
"kernelspec": {
123+
"display_name": "Python 3 (ipykernel)",
124+
"language": "python",
125+
"name": "python3"
126+
},
127+
"language_info": {
128+
"codemirror_mode": {
129+
"name": "ipython",
130+
"version": 3
131+
},
132+
"file_extension": ".py",
133+
"mimetype": "text/x-python",
134+
"name": "python",
135+
"nbconvert_exporter": "python",
136+
"pygments_lexer": "ipython3",
137+
"version": "3.13.5"
138+
}
139+
},
140+
"nbformat": 4,
141+
"nbformat_minor": 5
142+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import typing
2+
3+
4+
def fibonacci() -> typing.Generator[int, None, None]:
5+
current, nxt = 0, 1
6+
while True:
7+
current, nxt = nxt, nxt + current
8+
yield current
9+
10+
11+
def multiples_of(collection: typing.Iterable[int], number: int) -> typing.Generator[int, None, None]:
12+
for n in collection:
13+
if n % number == 0:
14+
yield n

0 commit comments

Comments
 (0)