beginner · python

Python Beginner Foundations

A practical introduction to Python that begins with small runnable examples and develops understanding of values, control flow, collections, functions, files, errors, and object-oriented design. Learners progressively combine these ideas to read, reason about, and write clear Python programs.

What you could build

  • A command-line number guessing game with input validation and repeated attempts.
  • A text-based quiz that calculates a score from stored questions and answers.
  • A contact list that stores, searches, updates, and removes entries.
  • A personal expense tracker that reads and writes records to a file.
  • A simple text analyzer that counts words, lines, and character frequencies.

You pick the project at the start — these are examples, not a fixed list.

What you'll be able to do

  • Read and predict the results of Python code involving variables, data types, conditions, loops, strings, lists, dictionaries, and sets.
  • Write functions with parameters, return values, default arguments, keyword arguments, and local scope, then organize related definitions in modules.
  • Read and write text files using appropriate paths and modes, manage files with with statements, and handle common exceptions with try, except, and finally.
  • Define classes, create and initialize instances, change object state, call methods, and reason about identity, inheritance, class attributes, and composition.
  • Combine Python fundamentals to explain and write small, clear programs that process input, transform data, repeat actions, and respond reliably to errors.

Who this is for

This course is for complete beginners or early Python learners who want a structured path from simple expressions to clear programs using functions, files, errors, and objects. It fits learners who want to understand and explain Python code rather than memorize isolated syntax.

What you should already know

  • Basic computer skills, including typing code and working with files and folders.
  • Access to a Python 3 environment where you can run short programs.

How a lesson actually goes

Lesson 1
TutorWelcome to Python Beginner Foundations. We will begin with very small, runnable examples and gradually learn how Python stores values, makes decisions, repeats actions, works with collections, and organizes code. In this first step, let’s distinguish the code we write from the result Python produces: what do you expect to happen when Python runs print("Hello")?
YouI think it displays Hello. I’m not sure whether print itself is part of the output or whether Python removes it.
TutorThat is the right result. print("Hello") is the source code, while Hello is the text displayed as a result of running it; the word print is not displayed. Now compare it with entering the expression 2 + 3: what result would you expect, and how is that different from print("2 + 3")?
You2 + 3 should give 5, but print("2 + 3") probably shows 2 + 3 because the quotation marks make it text. I’m guessing the expression is calculated but the quoted version is not.
TutorExactly. 2 + 3 is an expression whose value is the number 5, while "2 + 3" is a string containing those characters. With print("2 + 3"), Python displays that string without calculating it. This distinction between values and text will matter when we reach input, comparisons, and data processing.
TutorBefore we move on, explain in your own words what Python evaluates in 2 + 3 and what it displays in print("Hello"). I’ll use your explanation to decide whether to add another example or continue to variables.

Written from this course's first lesson to show the format — not a recording of a real session.

Course content

marks each module's capstone lesson.

01First Steps7 lessons

This module introduces the Python learning path and establishes the fundamentals needed to read and write small programs. Learners will run Python code, evaluate expressions, store values, recognize common data types, receive user input, and connect these ideas in a short synthesis assessment.

  • Course Introduction

    Welcome and orientation to Python Beginner Foundations. The course progresses from runnable examples through values, control flow, collections, functions, files, errors, and object-oriented design.

  • Running Python Code

    Python code is written as statements that an interpreter reads and executes. Learners identify how a Python environment accepts code and reports its result.

  • Expressions

    An expression is code that produces a value. Learners use literals and arithmetic operators while reasoning about evaluation and operator precedence.

  • Variables

    Variables provide names for values so those values can be reused and updated. Learners trace assignments and determine which value a variable refers to at a given point in a program.

  • Data Types

    A data type describes the kind of value Python is working with, such as an integer, floating-point number, string, or Boolean. Learners distinguish values that may look similar but behave differently because of their types.

  • Input

    The input operation pauses execution to receive text from a user and returns that text to the program. Learners store the returned value and reason about its type before using it.

  • First Steps Synthesis

    This synthesis assessment checks whether learners can connect the module's foundational ideas in execution order. Learners predict results, identify value types, and explain how data moves through a short sequence of Python statements.

02Decisions and Repetition13 lessons

This module introduces Boolean reasoning, comparisons, branching, and repetition in Python. Learners will predict how conditions are evaluated, choose between alternative paths, repeat actions with while and for loops, control loop execution, and synthesize these ideas to trace and reason about programs with changing control flow.

  • Boolean Values

    Boolean values represent two logical states: true and false. They are used to express and evaluate conditions in Python.

  • Comparison Operators

    Comparison operators test relationships between values, such as equality, inequality, and ordering. Each comparison produces a Boolean result.

  • Boolean Operators

    Boolean operators combine or reverse logical conditions. Their evaluation determines whether multiple requirements are all met, at least one is met, or a condition is reversed.

  • Truthiness

    Python evaluates many non-Boolean values in a Boolean context. Understanding truthy and falsy values helps explain how conditions behave when they do not contain an explicit comparison.

  • If Statements

    An if statement makes execution conditional. Python evaluates its condition and runs the indented block only when that condition is true.

  • Else Clauses

    An else clause provides an alternative path for an if statement. Its block runs when the associated condition does not hold.

  • Elif Clauses

    An elif clause tests another condition when earlier conditions were false. In an if-elif-else structure, Python executes the block belonging to the first true condition.

  • While Loops

    A while loop repeats an indented block as long as its condition remains true. The condition is checked before each iteration.

  • For Loops

    A for loop repeats a block once for each item produced by an iterable. The loop variable receives the next item at the start of each iteration.

  • Range

    The range function represents a sequence of regularly spaced integers, commonly used with for loops. Its start is included and its stop value is excluded.

  • Break Statements

    A break statement stops the nearest enclosing loop before its normal condition or iteration sequence is exhausted. Execution continues with the statement after that loop.

  • Continue Statements

    A continue statement abandons the remainder of the current iteration without ending the loop. Control moves to the next condition check or next item.

  • Decisions and Repetition Synthesis

    This synthesis assessment evaluates reasoning about changing control flow. Learners must predict execution paths, variable updates, repeated iterations, and the effects of decisions and loop-control statements.

03Collections and Text13 lessons

This module introduces Python strings and collection types. Learners will work with text through indexing, slicing, concatenation, and methods, then represent groups of values with lists, dictionaries, and sets. They will also trace iteration over collections and synthesize these concepts to reason about programs that transform and organize data.

  • Strings

    Strings represent text in Python and are written with matching quotation marks. Their values can be stored, compared, displayed, and combined in expressions.

  • String Indexing

    String indexing accesses one character at a time using a position in square brackets. Positive indexes count from the beginning, while negative indexes count from the end.

  • String Slicing

    String slicing selects a range of characters and returns a new string. The start is included, the stop is excluded, and an optional step controls how positions are selected.

  • String Concatenation

    The plus operator joins string values in order to create a new string. Concatenation requires compatible string operands and does not automatically insert spaces.

  • String Methods

    String methods provide named operations for tasks such as changing case, removing surrounding whitespace, and checking or replacing text. These operations return values and generally leave the original string unchanged.

  • Lists

    Lists hold multiple values in a defined order and are written with square brackets. A list may contain values of different types and may be stored in a variable.

  • List Indexing

    List indexing selects one element from an ordered list. The same positive-from-the-start and negative-from-the-end indexing rules used for strings apply to lists.

  • List Mutation

    Lists are mutable, so an element can be replaced and elements can be added or removed after the list is created. These operations change the existing list rather than producing an immutable text value.

  • Dictionaries

    Dictionaries represent mappings from unique keys to values and are written with braces containing key-value pairs. Unlike lists, dictionaries organize access around keys rather than integer positions.

  • Dictionary Lookup

    Dictionary lookup uses a key in square brackets to retrieve its associated value. A lookup succeeds when the key exists and raises a KeyError when the requested key is absent.

  • Sets

    Sets represent collections of distinct values without relying on positional indexing. They are useful for testing membership and eliminating duplicate values.

  • Collection Iteration

    Collections are iterable, so a for loop can assign each successive item to its loop variable. The items produced depend on the collection type, such as characters for strings and keys for dictionaries.

  • Collections and Text Synthesis

    This synthesis assesses how strings and collection types work together in a changing program. Learners must predict values, explain data transformations, and connect indexing, slicing, methods, mutation, lookup, membership, and iteration.

04Functions and Modules11 lessons

This module introduces functions as reusable units of Python code and modules as organized collections of definitions. Learners will define and call functions, pass arguments, return values, reason about scope and default parameters, and import and access names from modules.

  • Function Definitions

    A function definition gives a reusable block of code a name and specifies the statements that run when the function is used. Learners examine the def keyword, function name, parentheses, indentation, and function body.

  • Function Calls

    Calling a function uses its name followed by parentheses to execute its body. Learners distinguish defining a function from calling it and trace the order of statements around a call.

  • Parameters

    Parameters are names in a function definition that receive values from arguments supplied during a call. Learners trace how positional arguments are assigned to parameters and how those values are used inside the function.

  • Return Values

    The return statement ends a function call and sends a value back to the code that called the function. Learners distinguish returning a value from displaying a value and trace returned results stored in variables or used in expressions.

  • Local Scope

    Names created as parameters or assignments inside a function are local to that function by default. Learners trace name visibility and distinguish a function's local variables from names defined in the surrounding scope.

  • Default Parameters

    A default parameter value is used when a function call does not provide a corresponding argument. Learners compare calls that use the default with calls that replace it with an explicit value.

  • Keyword Arguments

    A keyword argument assigns a value to a parameter by naming that parameter in the call. Learners predict how keyword arguments affect matching and how they can be combined with positional arguments.

  • Module Files

    A module is a Python file containing definitions and executable statements that can be used from other code. Learners recognize how modules organize names and support reuse across files.

  • Import Statements

    The import statement loads a module so code can use definitions provided by that module. Learners distinguish the module being imported from the names available in the current namespace.

  • Module Namespaces

    An imported module's definitions are accessed through the module name and a dot, such as module_name.function_name. Learners trace this qualified lookup and distinguish module attributes from local names.

  • Functions and Modules Synthesis

    This synthesis assesses how function execution and module organization work together in a complete Python program. Learners reason about definitions, calls, argument binding, returned results, name visibility, imports, and qualified module access.

05Files and Reliability10 lessons

This module introduces file paths, file objects, reading and writing text, and reliable resource management. Learners will open files in appropriate modes, use with statements to manage them safely, recognize common file-related exceptions, handle failures with try and except, and ensure cleanup with finally before synthesizing these skills.

  • File Paths

    A file path identifies the location of a file or directory. Relative paths are interpreted from the program's current working directory, while absolute paths identify a location from a root location.

  • Opening Files

    The open function connects a Python program to a file and returns a file object. The file object provides operations for reading from or writing to that file.

  • File Modes

    A file mode determines how an opened file may be used. Read mode accesses existing content, write mode replaces or creates content, and append mode adds content to the end.

  • Reading Files

    A file opened for reading can provide its contents as text. Reading advances the file's current position, so later reads begin where the previous read ended.

  • Writing Files

    The write operation sends text from a Python program to a file. The resulting placement of that text depends on whether the file was opened in write mode or append mode.

  • With Statements

    A with statement manages a resource for the duration of a block. When used with a file, it closes the file automatically after the block completes, including when the block exits because of an exception.

  • File Exceptions

    File operations can fail for reasons such as a missing path, insufficient permissions, or invalid data. Python represents many such failures as exceptions, including FileNotFoundError and PermissionError.

  • Try and Except

    A try block contains code that may raise an exception, and an except block provides a response for a specified exception type. Handling a matching exception allows program execution to continue through the handler instead of stopping at that point.

  • Finally Clauses

    A finally clause contains code that runs after the try and any matching except block finish. It runs whether the protected code succeeds or raises an exception, making it useful for actions that must always occur.

  • Files and Reliability Synthesis

    This synthesis combines file access and reliability techniques into a complete reasoning task. Learners analyze how paths, modes, file operations, resource management, exception handlers, and finally clauses determine both program behavior and file state.

06Objects and Synthesis11 lessons

This module introduces object-oriented design in Python. Learners will define classes, create objects, inspect object identity, manage attributes, initialize objects, use self, call methods, distinguish class attributes, understand inheritance, and represent relationships through composition before synthesizing these ideas in a complete program trace.

  • Class Definitions

    A class definition describes the shared structure and behavior that objects of a particular type can have. Learners examine class syntax and distinguish a class definition from the objects created from it.

  • Instances

    An instance is an individual object created from a class. Learners trace a class call and identify the resulting object as a distinct instance of that class.

  • Object Identity

    Object identity describes whether references point to one exact object in memory. Learners use identity reasoning to distinguish shared references from separately created instances.

  • Instance Attributes

    Instance attributes store data associated with one particular object. Learners trace attribute lookup and assignment to determine how an individual instance's state changes.

  • Object Initialization

    The __init__ method runs during instance creation and establishes the object's initial attributes. Learners connect arguments supplied to a class call with the resulting initialized state.

  • Self Parameter

    The self parameter gives an instance method access to the particular object on which it was called. Learners trace self-based attribute access and distinguish it from other parameters.

  • Instance Methods

    Instance methods are functions defined in a class that operate on a particular instance. Learners follow method lookup, argument passing, and returned values for calls made with dot notation.

  • Class Attributes

    Class attributes are values stored on the class and available through instances when no instance attribute shadows them. Learners distinguish shared class-level data from data stored separately on each instance.

  • Inheritance

    Inheritance allows a subclass to receive behavior and structure from a parent class. Learners determine which definition is used when a subclass does or does not provide its own attribute or method.

  • Composition

    Composition represents a relationship in which an object contains a reference to another object. Learners trace attribute access across contained objects to understand how objects collaborate.

  • Objects and Synthesis

    This synthesis assesses how object-oriented concepts interact in a complete Python program. Learners reason about definitions, object creation, identity, attribute lookup, method execution, inheritance, and contained objects as program state changes.

Questions

Do I need prior Python experience?

No. The course starts with running a single Python statement, evaluating expressions, assigning variables, and identifying basic data types.

Will this cover more than basic syntax?

Yes. You will progress through control flow, collections, functions, modules, files, exception handling, and object-oriented design, with synthesis lessons that require you to trace and explain complete programs.

How much programming practice is included?

Lessons use small runnable examples and focused assessments. You will repeatedly predict results, trace execution, and write or revise code as concepts become more complex.

Does the course teach file handling and errors?

Yes. You will work with relative and absolute paths, file modes, reading and writing text, with statements, common file exceptions, and try, except, and finally.

Will I learn object-oriented Python?

Yes. The final module covers classes, instances, identity, attributes, initialization, self, methods, class attributes, inheritance, and composition.

The first lesson is ten minutes away.

Free while codeset is early. You choose what you're building before the first lesson starts, and the course is taught around it.

Start this course

Other courses

Python Beginner Foundations · codeset