Skip to content

Commit f6ff0b1

Browse files
committed
Python first hour
1 parent d228cea commit f6ff0b1

3 files changed

Lines changed: 461 additions & 1 deletion

File tree

.vscode/settings.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,6 @@
88
"azureFunctions.projectLanguage": "Python",
99
"azureFunctions.projectRuntime": "~4",
1010
"debug.internalConsoleOptions": "neverOpen",
11-
"azureFunctions.projectLanguageModel": 2
11+
"azureFunctions.projectLanguageModel": 2,
12+
"python-envs.defaultEnvManager": "ms-python.python:system"
1213
}
Lines changed: 306 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,306 @@
1+
{
2+
"cells": [
3+
{
4+
"cell_type": "markdown",
5+
"metadata": {},
6+
"source": [
7+
"# Getting Started with Python\n",
8+
"Run each cell step by step."
9+
]
10+
},
11+
{
12+
"cell_type": "code",
13+
"execution_count": null,
14+
"metadata": {},
15+
"outputs": [],
16+
"source": [
17+
"print(\"Hello, world!\")"
18+
]
19+
},
20+
{
21+
"cell_type": "markdown",
22+
"metadata": {},
23+
"source": [
24+
"## Variables"
25+
]
26+
},
27+
{
28+
"cell_type": "code",
29+
"execution_count": null,
30+
"metadata": {},
31+
"outputs": [],
32+
"source": [
33+
"name = \"John\"\n",
34+
"age = 80\n",
35+
"print(name, age)"
36+
]
37+
},
38+
{
39+
"cell_type": "markdown",
40+
"metadata": {},
41+
"source": [
42+
"## f-strings"
43+
]
44+
},
45+
{
46+
"cell_type": "code",
47+
"execution_count": null,
48+
"metadata": {},
49+
"outputs": [],
50+
"source": [
51+
"print(f\"Hello {name}\")"
52+
]
53+
},
54+
{
55+
"cell_type": "markdown",
56+
"metadata": {},
57+
"source": [
58+
"## Math"
59+
]
60+
},
61+
{
62+
"cell_type": "code",
63+
"execution_count": null,
64+
"metadata": {},
65+
"outputs": [],
66+
"source": [
67+
"a = 10\n",
68+
"b = 3\n",
69+
"print(a + b, a * b)"
70+
]
71+
},
72+
{
73+
"cell_type": "markdown",
74+
"metadata": {},
75+
"source": [
76+
"## Conditions"
77+
]
78+
},
79+
{
80+
"cell_type": "code",
81+
"execution_count": null,
82+
"metadata": {},
83+
"outputs": [],
84+
"source": [
85+
"age = 20\n",
86+
"if age >= 18:\n",
87+
" print(\"Adult\")\n",
88+
"else:\n",
89+
" print(\"Minor\")"
90+
]
91+
},
92+
{
93+
"cell_type": "markdown",
94+
"metadata": {},
95+
"source": [
96+
"## Loops"
97+
]
98+
},
99+
{
100+
"cell_type": "code",
101+
"execution_count": null,
102+
"metadata": {},
103+
"outputs": [],
104+
"source": [
105+
"for i in range(5):\n",
106+
" print(i)"
107+
]
108+
},
109+
{
110+
"cell_type": "code",
111+
"execution_count": null,
112+
"id": "6369490b",
113+
"metadata": {},
114+
"outputs": [
115+
{
116+
"name": "stdout",
117+
"output_type": "stream",
118+
"text": [
119+
"Hello John\n",
120+
"Goodbye!\n"
121+
]
122+
}
123+
],
124+
"source": [
125+
"while True:\n",
126+
" name = input(\"Enter your name (or 'quit' to stop): \")\n",
127+
"\n",
128+
" if name.lower() == \"quit\":\n",
129+
" print(\"Goodbye!\")\n",
130+
" break\n",
131+
"\n",
132+
" print(f\"Hello {name}\")"
133+
]
134+
},
135+
{
136+
"cell_type": "code",
137+
"execution_count": null,
138+
"id": "76c311fe",
139+
"metadata": {},
140+
"outputs": [
141+
{
142+
"name": "stdout",
143+
"output_type": "stream",
144+
"text": [
145+
"5\n",
146+
"4\n",
147+
"3\n",
148+
"2\n",
149+
"1\n",
150+
"Blast off!\n"
151+
]
152+
}
153+
],
154+
"source": [
155+
"count = 5\n",
156+
"\n",
157+
"while count > 0:\n",
158+
" print(count)\n",
159+
" count -= 1\n",
160+
"\n",
161+
"print(\"Blast off!\")"
162+
]
163+
},
164+
{
165+
"cell_type": "markdown",
166+
"metadata": {},
167+
"source": [
168+
"## Lists"
169+
]
170+
},
171+
{
172+
"cell_type": "code",
173+
"execution_count": null,
174+
"metadata": {},
175+
"outputs": [],
176+
"source": [
177+
"names = [\"Jane\", \"Sorabh\"]\n",
178+
"for name in names:\n",
179+
" print(name)"
180+
]
181+
},
182+
{
183+
"cell_type": "markdown",
184+
"metadata": {},
185+
"source": [
186+
"## Mini Project: Simple Task List"
187+
]
188+
},
189+
{
190+
"cell_type": "code",
191+
"execution_count": null,
192+
"metadata": {},
193+
"outputs": [],
194+
"source": [
195+
"tasks = []\n",
196+
"\n",
197+
"tasks.append(\"Learn Python\")\n",
198+
"tasks.append(\"Install VS Code\")\n",
199+
"tasks.append(\"Build first project\")\n",
200+
"\n",
201+
"print(\"My tasks:\")\n",
202+
"for index, task in enumerate(tasks, start=1):\n",
203+
" print(f\"{index}. {task}\")"
204+
]
205+
},
206+
{
207+
"cell_type": "markdown",
208+
"metadata": {},
209+
"source": [
210+
"## Dictionaries"
211+
]
212+
},
213+
{
214+
"cell_type": "code",
215+
"execution_count": null,
216+
"metadata": {},
217+
"outputs": [],
218+
"source": [
219+
"person = {\n",
220+
" \"name\": \"John\",\n",
221+
" \"role\": \"Teacher\",\n",
222+
" \"topic\": \"Python\"\n",
223+
"}\n",
224+
"\n",
225+
"print(person)\n",
226+
"print(person[\"name\"])\n",
227+
"print(person[\"role\"])\n",
228+
"print(person[\"topic\"])"
229+
]
230+
},
231+
{
232+
"cell_type": "markdown",
233+
"metadata": {},
234+
"source": [
235+
"## Functions"
236+
]
237+
},
238+
{
239+
"cell_type": "code",
240+
"execution_count": null,
241+
"metadata": {},
242+
"outputs": [],
243+
"source": [
244+
"def greet(name):\n",
245+
" return f\"Hello {name}\"\n",
246+
"\n",
247+
"print(greet(\"World\"))"
248+
]
249+
},
250+
{
251+
"cell_type": "markdown",
252+
"metadata": {},
253+
"source": [
254+
"## Mini Project: Interactive Version"
255+
]
256+
},
257+
{
258+
"cell_type": "code",
259+
"execution_count": null,
260+
"metadata": {},
261+
"outputs": [],
262+
"source": [
263+
"# Interactive version\n",
264+
"\n",
265+
"tasks = []\n",
266+
"\n",
267+
"while True:\n",
268+
" print(\"\\nSimple Task Tracker\")\n",
269+
" print(\"1. Add task\")\n",
270+
" print(\"2. View tasks\")\n",
271+
" print(\"3. Exit\")\n",
272+
"\n",
273+
" choice = input(\"Choose an option: \")\n",
274+
"\n",
275+
" if choice == \"1\":\n",
276+
" task = input(\"Enter a task: \")\n",
277+
" tasks.append(task)\n",
278+
" print(\"Task added.\")\n",
279+
"\n",
280+
" elif choice == \"2\":\n",
281+
" if len(tasks) == 0:\n",
282+
" print(\"No tasks yet.\")\n",
283+
" else:\n",
284+
" print(\"Your tasks:\")\n",
285+
" for index, task in enumerate(tasks, start=1):\n",
286+
" print(f\"{index}. {task}\")\n",
287+
"\n",
288+
" elif choice == \"3\":\n",
289+
" print(\"Goodbye!\")\n",
290+
" break\n",
291+
"\n",
292+
" else:\n",
293+
" print(\"Invalid choice. Try again.\")\n"
294+
]
295+
}
296+
],
297+
"metadata": {
298+
"kernelspec": {
299+
"display_name": "Python 3",
300+
"language": "python",
301+
"name": "python3"
302+
}
303+
},
304+
"nbformat": 4,
305+
"nbformat_minor": 5
306+
}

0 commit comments

Comments
 (0)