I’m new to programming
Start with the course’s introductory lectures and assignments, then practice one small programming idea at a time.
Start with: Introduction to Computer Science and Programming in Python
RedLectern topic
Learn Python fundamentals, from expressions and control flow to organizing and testing programs.
For: Learners at different starting points, from people new to programming to programmers new to Python.
After this page you can: Write small Python programs, choose suitable data structures, and organize code into reusable parts.
Page reviewed
Part of: Computer Science › Programming
Python is a general-purpose programming language whose syntax and dynamic typing support scripting and application development. It provides high-level data structures and an object-oriented approach. The official tutorial introduces core language concepts but assumes basic programming knowledge, so it suits learners who can already follow a simple program.
Study by trying small expressions, then reading examples and changing them in an interpreter: tutorial examples are self-contained and recommend hands-on use. MIT course materials offer another structured route with lectures, assignments, and exercises.
Start with the course’s introductory lectures and assignments, then practice one small programming idea at a time.
Start with: Introduction to Computer Science and Programming in Python
Use the official tutorial to get oriented to Python, and try its examples in an interpreter as you read.
Start with: The Python Tutorial
Read the file section and focus on how a context manager handles cleanup.
Start with: Input and Output: Reading and Writing Files
Try an expression, then trace how a condition or loop changes the next step in a program.
The course materials include lectures on branching and iteration.
if statement
A statement that selects a branch based on a condition.
for loop
A loop that iterates over items in a sequence.
What values does `sum(range(4))` add together, and what result does the Python tutorial show?
It adds 0, 1, 2, and 3; the result is 6.
Practice turning a repeated task into a function, then choose a collection that suits the information you need to represent.
The tutorial explains how to define functions and use parameters.
function
A named piece of code that can be called, with parameters and a body of statements.
dictionary
A collection of unique keys associated with values.
The tutorial’s dictionary example stores a value for the key `'jack'`. What value does it retrieve for that key?
It retrieves 4098.
Follow one value through a program: where it is defined, how it is saved or read, and what should happen if an operation fails.
The tutorial covers reading and writing files and saving structured data.
The tutorial distinguishes syntax errors from exceptions and explains handling exceptions.
module
A file containing Python definitions and statements that can be imported.
exception
An error detected while a program is executing.
Why can `with` be useful when opening a file?
It closes the file after the `with` suite finishes, even if an exception occurs.
Use a small example to decide whether related data and behavior belong together, then write down what response you expect for a particular input.
The documentation describes test cases as checks of a specific response to particular inputs.
The course materials include lectures on object-oriented programming, classes, testing, and debugging.
class
A way to bundle data and functionality and create a type of object.
test case
A check for a specific response to a particular set of inputs.
A test checks the response to one input. What should it specify?
It should specify the input and the response expected for it.
No recent updates are available.
Allen B. Downey · 2015
University course materials assign its second edition, and faculty review it as a beginner resource covering core Python syntax.
Luciano Ramalho · 2022
A Yale Python course lists the second edition, and a USENIX review describes it as a book about how Python works.
John M. Zelle · 2016
A university syllabus names it as required reading, and Python’s community book list identifies it as a CS1 textbook using Python.
Wes McKinney · 2022
A university syllabus assigns the third edition, whose author describes it as a resource for learning data work in Python.
Al Sweigart · 2019
A university course recommends it as an alternative introductory text; the author provides the full text online.
Eric Matthes · 2022
The publisher describes a progression from core programming concepts to projects in games, data visualization, and web apps.
Listed as Python courses: