Skip to content

Commit 0987990

Browse files
committed
Add terminology
1 parent 3be6b1e commit 0987990

File tree

2 files changed

+361
-213
lines changed

2 files changed

+361
-213
lines changed
Lines changed: 361 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,361 @@
1+
{
2+
"cells": [
3+
{
4+
"cell_type": "markdown",
5+
"id": "7d9726ec",
6+
"metadata": {},
7+
"source": [
8+
"<a target=\"_blank\" href=\"https://colab.research.google.com/github/lukebarousse/Python_Data_Analytics_Course/blob/main/1_Basics/00_Intro_To_Programming.ipynb\">\n",
9+
" <img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/>\n",
10+
"</a>"
11+
]
12+
},
13+
{
14+
"cell_type": "markdown",
15+
"id": "121fe821",
16+
"metadata": {},
17+
"source": [
18+
"## Python 101\n",
19+
"\n",
20+
"#### Terms to know:\n",
21+
"- **Object**\n",
22+
"- **Variable**\n",
23+
"- **Function**\n",
24+
"- **Class**\n",
25+
"- **Method**\n",
26+
"- **Attribute**"
27+
]
28+
},
29+
{
30+
"cell_type": "markdown",
31+
"id": "c1ea1f9e",
32+
"metadata": {},
33+
"source": [
34+
"### Objects: The Data Records\n",
35+
"\n",
36+
"In data analytics, an object is like a record in your spreadsheet. Each record can have multiple fields, such as job title, location, and salary.\n",
37+
"\n",
38+
"**Object**: A data record with fields.\n"
39+
]
40+
},
41+
{
42+
"cell_type": "code",
43+
"execution_count": 69,
44+
"id": "968ee59f",
45+
"metadata": {},
46+
"outputs": [
47+
{
48+
"data": {
49+
"text/plain": [
50+
"'Data Analyst'"
51+
]
52+
},
53+
"execution_count": 69,
54+
"metadata": {},
55+
"output_type": "execute_result"
56+
}
57+
],
58+
"source": [
59+
"\"Data Analyst\""
60+
]
61+
},
62+
{
63+
"cell_type": "code",
64+
"execution_count": 70,
65+
"id": "53b471a2",
66+
"metadata": {},
67+
"outputs": [
68+
{
69+
"data": {
70+
"text/plain": [
71+
"90000"
72+
]
73+
},
74+
"execution_count": 70,
75+
"metadata": {},
76+
"output_type": "execute_result"
77+
}
78+
],
79+
"source": [
80+
"90000"
81+
]
82+
},
83+
{
84+
"cell_type": "markdown",
85+
"id": "fe74bb60",
86+
"metadata": {},
87+
"source": [
88+
"### Variables: The Building Blocks\n",
89+
"\n",
90+
"Think of a variable as a cell in an Excel spreadsheet. You can store data in it, like a number, text, or a formula.\n",
91+
"\n",
92+
"**Variable**: A named cell that stores an object."
93+
]
94+
},
95+
{
96+
"cell_type": "markdown",
97+
"id": "f667cde9",
98+
"metadata": {},
99+
"source": []
100+
},
101+
{
102+
"cell_type": "code",
103+
"execution_count": 71,
104+
"id": "0fb0d189",
105+
"metadata": {},
106+
"outputs": [],
107+
"source": [
108+
"job_title = \"Data Analyst\"\n",
109+
"job_location = \"United States\"\n",
110+
"job_salary = 90000"
111+
]
112+
},
113+
{
114+
"cell_type": "markdown",
115+
"id": "c246c6c4",
116+
"metadata": {},
117+
"source": [
118+
"### Functions: The General Tools\n",
119+
"\n",
120+
"Functions are like custom formulas in Excel. They perform tasks that can be applied to different sets of data.\n",
121+
"\n",
122+
"**Function**: A reusable piece of code that performs a specific task."
123+
]
124+
},
125+
{
126+
"cell_type": "code",
127+
"execution_count": 72,
128+
"id": "66b6ee25",
129+
"metadata": {},
130+
"outputs": [],
131+
"source": [
132+
"def display_info(title, location, salary):\n",
133+
" return print(f\"JOB: {title}\\nLOCATION: {location}\\nSALARY: ${salary:,.0f}\")"
134+
]
135+
},
136+
{
137+
"cell_type": "code",
138+
"execution_count": 73,
139+
"id": "a453263c",
140+
"metadata": {},
141+
"outputs": [
142+
{
143+
"name": "stdout",
144+
"output_type": "stream",
145+
"text": [
146+
"JOB: Data Analyst\n",
147+
"LOCATION: United States\n",
148+
"SALARY: $90,000\n"
149+
]
150+
}
151+
],
152+
"source": [
153+
"job_title = \"Data Analyst\"\n",
154+
"job_location = \"United States\"\n",
155+
"job_salary = 90000\n",
156+
"\n",
157+
"display_info(job_title, job_location, job_salary)"
158+
]
159+
},
160+
{
161+
"cell_type": "markdown",
162+
"id": "b7fb6cbf",
163+
"metadata": {},
164+
"source": [
165+
"### Classes: The Template of Objects\n",
166+
"\n",
167+
"A class is like a template for your records in Excel. It defines the fields that each record will have.\n",
168+
"\n",
169+
"**Class**: A template for creating objects (records).\n"
170+
]
171+
},
172+
{
173+
"cell_type": "code",
174+
"execution_count": 74,
175+
"id": "2cfd7804",
176+
"metadata": {},
177+
"outputs": [],
178+
"source": [
179+
"class JobPost:\n",
180+
" def __init__(self, title, location, salary):\n",
181+
" self.title = title\n",
182+
" self.location = location\n",
183+
" self.salary = salary\n",
184+
"\n",
185+
" def display_info(self):\n",
186+
" return print(f\"JOB: {self.title}\\nLOCATION: {self.location}\\nSALARY: ${self.salary:,.0f}\")"
187+
]
188+
},
189+
{
190+
"cell_type": "code",
191+
"execution_count": 75,
192+
"id": "d0f7b6c5",
193+
"metadata": {},
194+
"outputs": [
195+
{
196+
"data": {
197+
"text/plain": [
198+
"__main__.JobPost"
199+
]
200+
},
201+
"execution_count": 75,
202+
"metadata": {},
203+
"output_type": "execute_result"
204+
}
205+
],
206+
"source": [
207+
"JobPost"
208+
]
209+
},
210+
{
211+
"cell_type": "markdown",
212+
"id": "f5537cd8",
213+
"metadata": {},
214+
"source": [
215+
"### Attributes: The Variables of an Object\n",
216+
"\n",
217+
"Attributes are like the columns in your spreadsheet. Each attribute stores specific data for each record.\n",
218+
"\n",
219+
"**Attribute**: A field in a record, defined by its class.\n"
220+
]
221+
},
222+
{
223+
"cell_type": "code",
224+
"execution_count": 76,
225+
"id": "38341fa0",
226+
"metadata": {},
227+
"outputs": [],
228+
"source": [
229+
"class JobPost:\n",
230+
" def __init__(self, title, location, salary):\n",
231+
" self.title = title # Attribute\n",
232+
" self.location = location # Attribute\n",
233+
" self.salary = salary # Attribute"
234+
]
235+
},
236+
{
237+
"cell_type": "code",
238+
"execution_count": 77,
239+
"id": "dcd89f8a",
240+
"metadata": {},
241+
"outputs": [],
242+
"source": [
243+
"job = JobPost(\"Data Engineer\", \"New York, NY\", 425000)"
244+
]
245+
},
246+
{
247+
"cell_type": "code",
248+
"execution_count": 78,
249+
"id": "fbd5b34d",
250+
"metadata": {},
251+
"outputs": [
252+
{
253+
"data": {
254+
"text/plain": [
255+
"'Data Engineer'"
256+
]
257+
},
258+
"execution_count": 78,
259+
"metadata": {},
260+
"output_type": "execute_result"
261+
}
262+
],
263+
"source": [
264+
"job.title"
265+
]
266+
},
267+
{
268+
"cell_type": "code",
269+
"execution_count": 79,
270+
"id": "a6ccd019",
271+
"metadata": {},
272+
"outputs": [
273+
{
274+
"data": {
275+
"text/plain": [
276+
"425000"
277+
]
278+
},
279+
"execution_count": 79,
280+
"metadata": {},
281+
"output_type": "execute_result"
282+
}
283+
],
284+
"source": [
285+
"job.salary"
286+
]
287+
},
288+
{
289+
"cell_type": "markdown",
290+
"id": "87300d79",
291+
"metadata": {},
292+
"source": [
293+
"### Methods: The Functions of an Object\n",
294+
"\n",
295+
"Methods are like the built-in functions in Excel that operate on your records. They define actions that the records can perform.\n",
296+
"\n",
297+
"**Method**: A function defined inside a class that operates on its objects.\n"
298+
]
299+
},
300+
{
301+
"cell_type": "code",
302+
"execution_count": 80,
303+
"id": "7b3c7c94",
304+
"metadata": {},
305+
"outputs": [],
306+
"source": [
307+
"class JobPost:\n",
308+
" def __init__(self, title, location, salary):\n",
309+
" self.title = title\n",
310+
" self.location = location\n",
311+
" self.salary = salary\n",
312+
" \n",
313+
" def display_info(self):\n",
314+
" return print(f\"JOB: {self.title}\\nLOCATION: {self.location}\\nSALARY: ${self.salary:,.0f}\")"
315+
]
316+
},
317+
{
318+
"cell_type": "code",
319+
"execution_count": 81,
320+
"id": "00414ac1",
321+
"metadata": {},
322+
"outputs": [
323+
{
324+
"name": "stdout",
325+
"output_type": "stream",
326+
"text": [
327+
"JOB: Data Engineer\n",
328+
"LOCATION: New York, NY\n",
329+
"SALARY: $425,000\n"
330+
]
331+
}
332+
],
333+
"source": [
334+
"job = JobPost(\"Data Engineer\", \"New York, NY\", 425000)\n",
335+
"\n",
336+
"job.display_info()"
337+
]
338+
}
339+
],
340+
"metadata": {
341+
"kernelspec": {
342+
"display_name": "python_course",
343+
"language": "python",
344+
"name": "python3"
345+
},
346+
"language_info": {
347+
"codemirror_mode": {
348+
"name": "ipython",
349+
"version": 3
350+
},
351+
"file_extension": ".py",
352+
"mimetype": "text/x-python",
353+
"name": "python",
354+
"nbconvert_exporter": "python",
355+
"pygments_lexer": "ipython3",
356+
"version": "3.11.9"
357+
}
358+
},
359+
"nbformat": 4,
360+
"nbformat_minor": 5
361+
}

0 commit comments

Comments
 (0)