Chapter 31
Foundations of Python and fixing NameErrors
Foundations of Python and fixing NameErrors
First, for a complete beginner
This introductory tutorial gets you started with the basics.
https://chatgpt.com/share/68063082-c2d8-8012-8d45-fa674aa1c1ed
Next: a comprehensive briefing on Python
I'm going to defer to an AI friend for this, because these explanations are so well written with great examples. Copy and paste the code examples into a new cell to give them a try. Pick whichever section(s) you'd like to brush up on.
Python imports:
https://chatgpt.com/share/672f9f31-8114-8012-be09-29ef0d0140fb
Python functions including default arguments:
https://chatgpt.com/share/672f9f99-7060-8012-bfec-46d4cf77d672
Python strings, including slicing, split/join, replace and literals:
https://chatgpt.com/share/672fb526-0aa0-8012-9e00-ad1687c04518
Python f-strings including number and date formatting:
https://chatgpt.com/share/672fa125-0de0-8012-8e35-27918cbb481c
Python lists, dicts and sets, including the get() method:
https://chatgpt.com/share/672fa225-3f04-8012-91af-f9c95287da8d
Python files including modes, encoding, context managers, Path, glob.glob:
https://chatgpt.com/share/673b53b2-6d5c-8012-a344-221056c2f960
Python classes:
https://chatgpt.com/share/672fa07a-1014-8012-b2ea-6dc679552715
Pickling Python objects and converting to JSON:
https://chatgpt.com/share/673b553e-9d0c-8012-9919-f3bb5aa23e31
With this in mind - understanding NameErrors in Python
It's quite common to hit a NameError in python. With foundational knowledge, you should always feel equipped to debug a NameError and get to the bottom of it.
The most common reason if you're working in a Notebook is that you haven't executed all the cells in order, so the Kernel does not have something defined.
If you're unsure how to fix a NameError, please see this initial guide and this second guide with exercises, and work through them both until you have high confidence.
There's some repetition here, so feel free to skip it if you're already confident.
After this, a NameError should never give you problems again!
