Core programming fundamentals · Lesson 6 of 60 · Code lesson, JavaScript or Python · Optional
Expressions and statements
An expression is code that produces a value, such as width * height.
A statement is a complete instruction that does something, such as storing a value or printing one.
Statements are often built from expressions, like storing the result of an expression in a variable.
Worked example
In JavaScript, a statement usually ends with a semicolon.
const width = 6;
const height = 3;
const area = width * height;
console.log(area);Output: 18
In Python, each statement normally sits on its own line.
width = 6
height = 3
area = width * height
print(area)Output: 18
Your turn
Replace the 0 with an expression, so area holds the width times the height and the program prints 24.
Expected output: 24
Loading your practice…
Preparing your workspace…