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
Computer Science1 course

Programming

Variables, conditionals, loops, functions and object-oriented design.

About Programming

Introductory programming teaches how to turn a problem into instructions a computer can run. The core building blocks are the same in every language: variables, conditions, loops, functions and collections such as lists and dictionaries.

The real skill is decomposition. A program that grades a quiz is a loop over answers, a comparison for each one and a running total, and each part can be written and tested on its own. Debugging, the habit of predicting what code should do and finding where it does something else, matters as much as writing code.

Programming is used in software development, data analysis, science, finance, design and automation of everyday tasks. Even a short script that renames files or cleans a spreadsheet can save hours, and the problem-solving habits it teaches transfer to mathematics and other technical subjects.

Introduction to Programming

Program design with tracing exercises. (High school)

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.

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.

Full Introduction to Programming course outline

How to study Programming

  • Type and run small examples instead of only reading them.
  • Predict the output before running code, then explain any difference.
  • Write functions that do one thing, and test them with ordinary, edge and invalid inputs.
  • Read error messages from the top: the line number and error type usually point straight at the problem.
Before you start
Comfort with basic algebra (variables and expressions).
Where it leads
Data structures, algorithms and object-oriented design. Many students also branch into web development, data analysis or automation, which use the same fundamentals.

Key terms in Programming

Variable
A named place in memory holding a value that the program can read and change, such as a running total.
Conditional
An if/else statement that runs different code depending on whether a condition is true.
Loop
Code that repeats: a for loop runs a set number of times, while a while loop runs until its condition becomes false.
Function
A named, reusable block of code with inputs (parameters) and usually an output (return value).
Off-by-one error
A bug where a loop or index runs one step too far or too short, often from mixing up << and ≤\le.
Debugging
Finding and fixing bugs by reproducing the problem, narrowing down where it starts and testing one change at a time.

More in Computer Science