Skip to content
  • Open the math solver
  • Ask the AI tutor
  • Find an AP course
  • Create a quiz
  • Open the calculator
  • Graphing Calculator
  • Browse all calculators
  • Read math guides
↑ ↓Enter to open · Esc to close
Solve a problem
ProgrammingHigh school2 topic explainers

Introduction to Programming course

Program design with tracing exercises.

Topics in this course

  1. 1.Control Flow

    Control flow is the order in which a program's statements run. By default, statements run top to bottom. Conditionals (`if`, `else if`, `else`) choose between branches based on a Boolean test, and loops (`for`, `while`) repeat a block until a condition changes.

    • A `for` loop suits a known number of repetitions; a `while` loop suits repeat-until-done.
    • Check boundary cases: zero iterations, one iteration and the last iteration.
    • Combine conditions with and, or and not; watch operator precedence.
    Quick check: How many times does a loop from i=0i = 0 while i<10i < 10, step 2, run?

    55

    Includes a worked example, 3 common mistakes and 3 practice questions with answers. Study control flow

  2. 2.Functions and Methods

    A function is a named, reusable block of code that takes inputs (parameters), does some work and usually returns an output. Functions let you write a piece of logic once, test it in isolation and call it from many places, which makes programs shorter and easier to reason about.

    • A function signature names the function, its parameters and (in typed languages) its return type.
    • `return` ends the function immediately and hands back a value.
    • Pure functions depend only on their inputs and have no side effects, which makes them easy to test.
    Quick check: If `f(x) = 2 * x + 1`, what is `f(f(3))`?

    1515

    Includes a worked example, 3 common mistakes and 3 practice questions with answers. Study functions and methods

Also part of this course

These topics belong to the course outline. Full explainers for them have not been written yet, so they are summarised here rather than given pages of their own.

Object-Oriented Programming
Classes, objects, inheritance and encapsulation.

Where to go next