Python Field Guide
Using AI while learning to code
| Learn to do it yourself | Have AI do it for you | |
|---|---|---|
| Writing & struggling with code | Productive struggle is what builds understanding
|
Being handed the answer skips the friction that builds understanding
|
| Reading & verifying code | Understanding programming fundamentals makes AI more useful — you can read and evaluate code you didn't write
|
Inefficient communication with AI if you don't fully understand what's going on, and AI code can look correct while being wrong or insecure
|
| On the job | Programming work still requires understanding:
|
AI will likely be available at work too — but it isn't what will get you hired |
swimlane-beta TB
accTitle: Using AI to learn
accDescr: AI walks you through setup before you start. You attempt each problem yourself with autocomplete off, then check whether you can explain why it works and whether it actually holds up — if either check fails, you describe what you tried rather than handing over your code, so AI explains the concept instead of fixing it, and you try again. Passing both checks means you understand it well enough for a practice problem, or for the code review, debugging, and interviews that are what your job actually tests.
subgraph You
you_help_setup(Need help setting up your computer to start programming?)
you_have_project(Do you have a project to work on?)
you_attempt(Attempt it yourself, autocomplete off so you understand everything that's there, utilize debug strategies)
you_writeup(Stuck? Write out your problem: what you expect to happen, what you're observing, what you've tried already, see if this helps you process or rethink your strategy)
you_finish("Learning to program means making mistakes, getting stuck, and eventually figuring things out and forming a mental model. That's the process that builds skills you can rely on to continue solving problems and detecting issues — ready for code review, debugging, and interviews, where AI won't be tested, your reasoning will. ")
end
subgraph AI
ai_help_setup(AI can help guide you through setup on your exact device — which could make getting started more accessible for beginners)
ai_suggest_problem(Suggests a problem based on your skill level, interests, and what you're trying to improve)
explain(With that context AI can provide more targeted, efficient help. Don't just paste the code/error, ask AI to explain what a line does, or what an error means — an explanation to help you understand concepts, be clear you do NOT want it to write code, just explain)
end
ai_help_setup ~~~ you_help_setup
ai_suggest_problem ~~~ you_have_project
you_help_setup -->|Yes| ai_help_setup
you_help_setup -->|No| you_have_project
ai_help_setup --> you_have_project
you_have_project -->|No| ai_suggest_problem
you_have_project -->|Yes| you_attempt
ai_suggest_problem --> you_attempt
you_attempt <--> you_writeup
you_attempt -->|Done!| you_finish
you_writeup --> |still stuck?| explain
explain --> you_attempt
explain ~~~ you_finish
%% Edge label text colored red if it leads into the AI lane, green
%% if it leads into the You lane, matching the lane colors. This is
%% linkStyle's "color" property (not background) — the one styling
%% mechanism mermaid applies from inside its own closed shadow
%% root, so it's the only thing that actually reaches the label.
linkStyle 0 color:#a33f3f
linkStyle 1 color:#3f6b52
linkStyle 3 color:#3f6b52
linkStyle 4 color:#a33f3f
linkStyle 7 color:#3f6b52
linkStyle 8 color:#a33f3f
classDef you fill:#3f6b521f,stroke:#3f6b52,stroke-width:2px,color:#3f6b52
classDef ai fill:#a33f3f1a,stroke:#a33f3f,stroke-width:2px,color:#a33f3f
class you_writeup,you_help_setup,you_have_project,you_attempt,you_finish you
class explain,ai_help_setup,ai_suggest_problem ai
style You fill:#3f6b521f,stroke:#3f6b52,color:#3f6b52
style AI fill:#a33f3f1a,stroke:#a33f3f,color:#a33f3f
Start
-
Write Python on your computer.
code editors:IDLEPycharmThonnyVS Code -
Storing, displaying, and inputting values.
Types
-
Kinds of values, and what you can do with them.
integers:+ - * / **// % divmodabsboolean expressionsintfloats:+ - * / **// % divmodabsboolean expressionsfloatroundstrings:+ * += *=boolean expressionscapitalizecombinecountendswithf-stringfindformatformat specinindexisalphaisdigitjoinlenlowerreplaceslicesplitstartswithstepstrstriptitleupper -
Multiple related values grouped into one container.
lists:+appendboolean expressionsclearcomprehensioncopycountcreatedelextendinindexinsertitemlenlistloopmaxminpopremovereverseslicesortsortedstepsumdictionaries:access a valueboolean expressionsclearcopydeldictgetitemskeylenlooppoppopitemupdatevaluevaluestuples:access itemsboolean expressionscountimmutableindexindexlenloopmaxminpackingsumtupleunpackingsets:addboolean expressionsclearcopydiscardisdisjointissubsetissupersetlenloopmaxminpopremovesetsumupdate| & - ^
Flow
-
Decision points that run code only if a condition is met.
if, elif, else:and, or, notboolean expressions -
Repeat a block of code multiple times.
for:enumerateloop a set number of timesloop through a collectionrangereversedzipwhile:andboolean expressionscounter and flag namesflagnotorsentinel
Organization
-
Package a named block of code to run it at any time.
def:combining argument typesdefaultsdocstringskeyword-onlyparameterspasspositional-onlyreturntype hintscalling a function:argumentskeywordrequiredreturn valueunpackingdecorators:argumentsidentityoriginal functionstackingwrapping -
Bundle related values and functions to a reusable blueprint for similar objects.
class:class attributesinstance attributesmethodsselfmethod decorators:@classmethod@property@staticmethodinheritance:adding attributes and methodsmultiple inheritanceoverridingsuper()polymorphism:duplicate method namesinheritanceencapsulation:@propertydouble underscoresingle underscore
Resources
-
Splitting code across files, and using someone else's code.
-
Read and write text files on your computer.
read():existingfunctionsmodesread()readline()readlines()seek()tell()write():appendcreatefunctionsmodesoverwritewrite()writelines()
Practices
-
Readable Python code, and polished UI.
PEP 8:blank linescommentsconstantsdocstringsindentationnamingorderquote stylewhitespacePythonic patterns:enumerate()is Nonemutable defaultstruthy checksEfficiency:big Ocommon optimizationsspacetimePolished UX:input validationmenusrandomizePolished UI:backgroundboldboxescolordividersescape sequencesformatting variableshighlightingmulti-line stringsprogress barsunderlineunicode symbols -
Resolve bugs, read and utilize exceptions.
kinds:bugsexceptionslogic errorsruntime errorssyntax errorsfixing:debugger tooldebugging strategiesisolate problemsprint debuggingrubber duck debuggingsyntax error messagetestingTODO / FIXMEtracebacks
Add-On Libraries
Utilities
-
Specialized containers: counting items, grouping with defaults, named tuples, fast queues.
-
Calculating and formatting dates and times.
-
Rounding, roots, constants, and logarithms.
-
Random numbers, random picks, shuffled order.
-
Regular expressions: searching, extracting, and replacing text by pattern.
-
Reading the system clock, pausing execution, and measuring elapsed time.
Data analysis
-
Reading and writing spreadsheets.
-
Charts and plots: line, bar, and scatter, built directly from plain Python data.
-
Fast numeric arrays, with math applied to a whole array at once instead of item by item.
-
Tabular data: rows and columns, like a spreadsheet, built on top of NumPy.
APIs
Web
-
Parsing HTML: finding tags, reading attributes and text, and turning a page into structured data.
Images
-
Opening, editing, and saving images, built around one Image object.
Computer vision
-
Real-time image and video analysis, built directly on NumPy arrays: color spaces, edge detection, face detection.
Desktop UIs
-
Creating desktop applications: text, buttons, dropdowns, forms, output, etc.
Games
-
Build small movement-based games with a pen cursor.
Testing
-
Writing and running tests: assertions, fixtures, and parametrizing.