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 number5 + 3
: an addition expressionprice * 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.
Want to learn more?
Join CodeFriends Plus membership or enroll in a course to start your journey.