Lecture

Expressions and Arithmetic

In data analysis, you often compute totals, differences, averages, and more.

Python does this through expressions, which are pieces of code that produce a result.


What Is an Expression?

An expression is any combination of values, variables, and operators that Python can evaluate to produce a result.

Some examples:

  • 42: a literal number
  • 5 + 3: an addition expression
  • price * quantity: a multiplication using variables

If Python can run it and return a value, it's an expression.


Arithmetic in Data Analysis

Data analysts use arithmetic to:

  • Add values (e.g., total sales)
  • Calculate growth rates or discounts
  • Find averages and differences

Learning to build expressions is the foundation for processing and analyzing real-world data.


What You'll Practice

In the code block below, you will:

  • Add and multiply numbers
  • Work with variables
  • Use expressions to calculate useful results

Run the examples and try changing the values to see how the output changes.

Quiz
0 / 1

Use an arithmetic expression to calculate the total sales from price and quantity.

The total sales can be calculated using the expression: .
price + quantity
price - quantity
price * quantity
price / quantity

Lecture

AI Tutor

Design

Upload

Notes

Favorites

Help

Code Editor

Run
Generate

Execution Result