# Imperative Programming

> Writing code as a list of steps that change values one at a time.

**Field:** Software Development  
**Category:** Programming Paradigms  
**Also known as:** Imperative Code, Procedural Programming

## Think of it like

Think of it like a recipe. Do this, then this, then this, and the cake is done.

## Definition

Imperative programming means writing code as a list of steps. Each step changes something. You tell the computer exactly how to reach the answer, one move at a time. Loops, if statements and variables that change are its main tools. Most beginners learn to code this way first.

## Example

Jack adds up three prices with a loop. Each turn adds one price to a running total, and the total ends at 12.

## Example code

```python
total = 0
for p in [3, 4, 5]:
    total = total + p
print(total)  # 12
```

Each step changes total, one price at a time.

## Why it matters

It is the closest match to how the machine works. Most code you meet is at least partly written this way.

## Common mistake

Writing a 50-step loop where one built-in call would do. Look for the tool that says what you want.

## Three principles

- **Step by step.** You say how.
- **Values change.** Each step updates them.
- **Loops and ifs.** Its main tools.

## Related terms

- [Declarative Programming](https://learn.benibix.com/term/development/declarative-programming)
- [Programming Paradigm](https://learn.benibix.com/term/development/programming-paradigm)
- [Loop](https://learn.benibix.com/term/development/loop)
- [Variable](https://learn.benibix.com/term/development/variable)

## Told apart from

- [Imperative vs Declarative Programming](https://learn.benibix.com/compare/imperative-vs-declarative-programming): Imperative code lists the steps to reach an answer, one change at a time. Declarative code says what answer you want and lets the tool pick the steps.

---

Source: https://learn.benibix.com/term/development/imperative-programming
Author: Behnia Zarei (a developer in Vienna, Austria, who builds and teaches data, AI and business intelligence at BENIBIX)
Publisher: BENIBIX Learn (https://learn.benibix.com/)
Last updated: 2026-11-17
Licence: CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Quote freely with attribution.
