← Python for AI
Python Fundamentals
An 8-week, hands-on introduction to Python — from your first print() to APIs, files, and object-oriented programming.
Course content
Module 1
Getting Started
- What is a programming language?Preview
- Why Python of all languages?
- How Python runs your code behind the scenes
- The story of Python: who built it, when, and why
- Set Python up on your own machine
- Comments: the notes Python never reads
- The print function, and shaping what comes out
- Variables: the boxes Python keeps for you
- The input function, and a program that asks questions
- Week 1 Recording
Module 2
Data, Text & Decisions
- Data types: how Python knows what it is dealing with
- Each type's own tools, and turning one type into another
- Text and its toolbox: len and count
- Swapping and deleting with replace
- Building text: from the plus operator to the f-string
- Breaking text with split and repeating with star
- Indexing and slicing: pulling one piece out of a text
- Cleaning text: invisible spaces and letter case
- Searching in text: is it there, and where
- Validating text, and wrapping up the chapter
- Submitting your work to CS50
- Week 2 Recording
Module 3
Numbers, Logic & Functions
- Numbers, and where the functions live
- The arithmetic operators
- Rounding numbers
- Random numbers and validating them
- Control flow, and true and false
- The comparison operators
- Combining conditions with and and or
- Inverting with not, and the order logic runs in
- Membership and identity: in and is
- if and else
- The elif chain
- Nested conditions, and the three other ways
- The inline if
- Building a real validator
- Reporting every issue
- Your first function, with def
- Week 3 Recording
Module 4
Loops & Repetition
- The for loop
- range and counting
- Building a result across a loop
- break and continue
- pass, and choosing between the three
- Nested loops
- The while loop
- The while True loop
- The chapter's final challenge
- Week 4 Recording
Module 5
Data Structures & Error Handling
- What is a data structure?
- Building a list
- Indexing and slicing a list
- Unpacking a list
- Inspecting a list
- Adding and removing
- Changing and sorting
- Nested lists
- Copying a list
- Combining lists
- Week 5 challenge
- When the input is broken
- Formatting output
- CS50 problems — round two
- Four CS50 problems, solved
- Week 5 Recording
Module 6
Dictionaries, Modules, APIs & JSON
- What is a dictionary?
- Reading from a dictionary
- Building and changing
- Dictionaries in real work
- Modules and packages
- Command-line arguments
- APIs and JSON
- CS50's problem set 4, solved
- Week 6 Recording
Module 7
Testing, Files, CSV & Regex
- Testing your own code
- pytest, and code you can test
- CS50's problem set 5, solved
- Files: where a program remembers
- Reading a file, line by line
- Several columns per line: CSV by hand
- The csv library
- Files that aren't text
- CS50's problem set 6, solved
- Patterns, instead of letters
- Anchors, sets and shortcuts
- Capturing and replacing
- When not to write a regex
- CS50's problem set 7, solved
- Week 7 Recording
Module 8
OOP, Final Project & AI
- Inventing your own type
- Methods, and magic methods
- A class that protects itself
- Inheritance, and a method that belongs to the class
- CS50's problem set 8, solved
- Submitting your CS50 final project
- From the browser to your code: the key and the setup
- Your first message: nothing but dictionaries
- The same message, with a library
- A chatbot with a memory
- The next step: from Python's alphabet to a job
- Week 8 Recording
