Skip to main content
Practice

Expressions and Arithmetic

In data analysis, we often need to calculate values — totals, differences, averages, and more.
Python lets us do this using expressions, which are pieces of code that produce results.


What Is an Expression?

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

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

Analysts rely on arithmetic for:

  • Summing values (e.g. total sales)
  • Calculating growth rates or discounts
  • Finding averages and differences

Understanding how to build expressions lets you process and analyze real-world data.


What You'll Practice

In the code block below, you’ll try:

  • Adding and multiplying numbers
  • Working with variables
  • Using expressions to calculate useful results

Try running the examples and modifying the values to see what changes.


What’s Next?

Next, we’ll look at string operations — how to work with text in Python. This is useful when analyzing names, categories, or comments in a dataset.

Want to learn more?

Join CodeFriends Plus membership or enroll in a course to start your journey.