# Statements and Expressions

> The two kinds of piece every line of code is made of. What a keyword is, why comments matter, and how to try a line out first.

**Course:** [Programming Basics](https://learn.benibix.com/learn/development-concepts)  
**Time:** 10 min

**After this lesson you can:**

- Tell a statement from an expression
- Spot a keyword in a line of Python
- Write a comment that helps the next reader

## What a statement is, and what an expression is

Code is made of two kinds of piece. A statement is one whole step, such as print("Hi"). An expression is a piece that works out to one value, such as 3 + 4, which works out to 7. Most statements have expressions inside them, the way a sentence has words inside it.

In Python, each statement usually sits on its own line. The program runs them from the top down, one at a time. A line like total = 3 + 4 is a statement. The 3 + 4 part is an expression. Python works out the expression first, then finishes the step.

Some words have a fixed job in the language. These are keywords, such as if, for, while, def and return. Python 3 has 35 of them. You cannot use one as a name for your own things, because Python would not know which job you meant.

A comment is a note for people. In Python it starts with a # sign, and Python skips everything after it on that line. A good comment says why the code does something, not what it does. The code already shows what. Only a person can explain why.

There is a quick way to try a single line. Type python on its own and you get a REPL, which stands for read, evaluate, print, loop. It waits at a >>> sign. Type 3 + 4 and it prints 7 straight away. It is ideal for testing one expression before it goes in a file.

The REPL shows the value of an expression without a print. A script does not. If a script holds the line 3 + 4, Python works it out and then throws it away. Nothing appears. To see a value from a script, wrap it in print.

A common mistake is a comment that repeats the code, like # add 1 above count = count + 1. It adds noise and goes stale when the code changes. Write fewer comments, and make each one say something the code cannot.

```python
>>> 3 + 4
7
>>> total = 3 + 4   # a statement with an expression inside
>>> total
7
>>> if = 5
SyntaxError: invalid syntax
```
In the REPL, an expression shows its value at once. The last line fails, because if is a keyword.

![A loop of four steps: read, run it, print, wait. Beside it, a terminal shows the line 2 + 3 typed after the >>> sign and the answer 5 printed underneath, then a fresh >>> sign waiting.](https://learn.benibix.com/diagrams/dev-repl.svg)

### Example: Lucy checks a sum before she uses it

Lucy needs the price of 12 pens at 0.35 each. She types 12 * 0.35 into the REPL and gets 4.2 back at once.

Happy with it, she puts total = 12 * 0.35 in her script. She adds one comment: # pens come in boxes of 12.

**Words in this lesson:** [Statement](https://learn.benibix.com/term/development/statement), [Expression](https://learn.benibix.com/term/development/expression), [Keyword](https://learn.benibix.com/term/development/keyword), [Comment](https://learn.benibix.com/term/development/comment), [Read-Eval-Print Loop (REPL)](https://learn.benibix.com/term/development/repl)

**Question:** Which of these is an expression?

**Answer:** 10 * 2, which works out to 20. An expression is any piece of code that works out to one value. 10 * 2 works out to 20, so it is an expression.

---

Source: https://learn.benibix.com/learn/development-concepts/statements-and-expressions
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-19
Licence: CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Quote freely with attribution.
