|
80 | 80 | "90000"
|
81 | 81 | ]
|
82 | 82 | },
|
| 83 | + { |
| 84 | + "cell_type": "markdown", |
| 85 | + "id": "1ef640ba", |
| 86 | + "metadata": {}, |
| 87 | + "source": [ |
| 88 | + "Everything in Python is an object; including functions and classes." |
| 89 | + ] |
| 90 | + }, |
| 91 | + { |
| 92 | + "cell_type": "code", |
| 93 | + "execution_count": 6, |
| 94 | + "id": "4d55db87", |
| 95 | + "metadata": {}, |
| 96 | + "outputs": [ |
| 97 | + { |
| 98 | + "name": "stdout", |
| 99 | + "output_type": "stream", |
| 100 | + "text": [ |
| 101 | + "\n" |
| 102 | + ] |
| 103 | + } |
| 104 | + ], |
| 105 | + "source": [ |
| 106 | + "print()" |
| 107 | + ] |
| 108 | + }, |
| 109 | + { |
| 110 | + "cell_type": "code", |
| 111 | + "execution_count": 7, |
| 112 | + "id": "aaa5da4b", |
| 113 | + "metadata": {}, |
| 114 | + "outputs": [ |
| 115 | + { |
| 116 | + "data": { |
| 117 | + "text/plain": [ |
| 118 | + "str" |
| 119 | + ] |
| 120 | + }, |
| 121 | + "execution_count": 7, |
| 122 | + "metadata": {}, |
| 123 | + "output_type": "execute_result" |
| 124 | + } |
| 125 | + ], |
| 126 | + "source": [ |
| 127 | + "str" |
| 128 | + ] |
| 129 | + }, |
83 | 130 | {
|
84 | 131 | "cell_type": "markdown",
|
85 | 132 | "id": "fe74bb60",
|
86 | 133 | "metadata": {},
|
87 | 134 | "source": [
|
88 |
| - "### Variables: The Building Blocks\n", |
| 135 | + "### Variables: The Reference to Objects\n", |
89 | 136 | "\n",
|
90 | 137 | "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 | 138 | "\n",
|
92 | 139 | "**Variable**: A named cell that stores an object."
|
93 | 140 | ]
|
94 | 141 | },
|
95 |
| - { |
96 |
| - "cell_type": "markdown", |
97 |
| - "id": "f667cde9", |
98 |
| - "metadata": {}, |
99 |
| - "source": [] |
100 |
| - }, |
101 | 142 | {
|
102 | 143 | "cell_type": "code",
|
103 |
| - "execution_count": 71, |
| 144 | + "execution_count": 1, |
104 | 145 | "id": "0fb0d189",
|
105 | 146 | "metadata": {},
|
106 | 147 | "outputs": [],
|
|
110 | 151 | "job_salary = 90000"
|
111 | 152 | ]
|
112 | 153 | },
|
| 154 | + { |
| 155 | + "cell_type": "code", |
| 156 | + "execution_count": 3, |
| 157 | + "id": "a03cbbf0", |
| 158 | + "metadata": {}, |
| 159 | + "outputs": [ |
| 160 | + { |
| 161 | + "data": { |
| 162 | + "text/plain": [ |
| 163 | + "(4594639152, 4594645744, 4593144944)" |
| 164 | + ] |
| 165 | + }, |
| 166 | + "execution_count": 3, |
| 167 | + "metadata": {}, |
| 168 | + "output_type": "execute_result" |
| 169 | + } |
| 170 | + ], |
| 171 | + "source": [ |
| 172 | + "# each variable has a unique identifier\n", |
| 173 | + "id(job_title), id(job_location), id(job_salary)" |
| 174 | + ] |
| 175 | + }, |
| 176 | + { |
| 177 | + "cell_type": "markdown", |
| 178 | + "id": "864e8619", |
| 179 | + "metadata": {}, |
| 180 | + "source": [ |
| 181 | + "Variables that reference the same object are the same." |
| 182 | + ] |
| 183 | + }, |
| 184 | + { |
| 185 | + "cell_type": "code", |
| 186 | + "execution_count": 2, |
| 187 | + "id": "4b917379", |
| 188 | + "metadata": {}, |
| 189 | + "outputs": [ |
| 190 | + { |
| 191 | + "data": { |
| 192 | + "text/plain": [ |
| 193 | + "'Data Analyst'" |
| 194 | + ] |
| 195 | + }, |
| 196 | + "execution_count": 2, |
| 197 | + "metadata": {}, |
| 198 | + "output_type": "execute_result" |
| 199 | + } |
| 200 | + ], |
| 201 | + "source": [ |
| 202 | + "lukes_job = job_title\n", |
| 203 | + "\n", |
| 204 | + "lukes_job" |
| 205 | + ] |
| 206 | + }, |
| 207 | + { |
| 208 | + "cell_type": "code", |
| 209 | + "execution_count": 5, |
| 210 | + "id": "fc07b63c", |
| 211 | + "metadata": {}, |
| 212 | + "outputs": [ |
| 213 | + { |
| 214 | + "data": { |
| 215 | + "text/plain": [ |
| 216 | + "(4594639152, 4594639152)" |
| 217 | + ] |
| 218 | + }, |
| 219 | + "execution_count": 5, |
| 220 | + "metadata": {}, |
| 221 | + "output_type": "execute_result" |
| 222 | + } |
| 223 | + ], |
| 224 | + "source": [ |
| 225 | + "# the id of the same object is the same\n", |
| 226 | + "id(job_title), id(lukes_job)" |
| 227 | + ] |
| 228 | + }, |
| 229 | + { |
| 230 | + "cell_type": "markdown", |
| 231 | + "id": "f367a47d", |
| 232 | + "metadata": {}, |
| 233 | + "source": [ |
| 234 | + "Variables may be assigned the same name, but aren't necessarily the same." |
| 235 | + ] |
| 236 | + }, |
| 237 | + { |
| 238 | + "cell_type": "code", |
| 239 | + "execution_count": 8, |
| 240 | + "id": "a5aa7f31", |
| 241 | + "metadata": {}, |
| 242 | + "outputs": [ |
| 243 | + { |
| 244 | + "data": { |
| 245 | + "text/plain": [ |
| 246 | + "(4594562480, 4594554352)" |
| 247 | + ] |
| 248 | + }, |
| 249 | + "execution_count": 8, |
| 250 | + "metadata": {}, |
| 251 | + "output_type": "execute_result" |
| 252 | + } |
| 253 | + ], |
| 254 | + "source": [ |
| 255 | + "job_title1 = \"Data Analyst\"\n", |
| 256 | + "job_title2 = \"Data Analyst\"\n", |
| 257 | + "\n", |
| 258 | + "# the id of the same object is the same\n", |
| 259 | + "id(job_title1), id(job_title2)" |
| 260 | + ] |
| 261 | + }, |
113 | 262 | {
|
114 | 263 | "cell_type": "markdown",
|
115 | 264 | "id": "c246c6c4",
|
116 | 265 | "metadata": {},
|
117 | 266 | "source": [
|
118 |
| - "### Functions: The General Tools\n", |
| 267 | + "### Functions: The Manipulators of Objects\n", |
119 | 268 | "\n",
|
120 | 269 | "Functions are like custom formulas in Excel. They perform tasks that can be applied to different sets of data.\n",
|
121 | 270 | "\n",
|
|
0 commit comments