Understanding Operators and
Operands in Python
Lesson Objectives
By the end of this lesson, students will be able to:
1. Define operators and operands.
2. Identify and use basic arithmetic operators in Python.
3. Evaluate expressions and understand their behavior in
interactive mode and scripts.
Sam
Operators and Operands
Operators are special symbols that represent
computations such as addition and multiplication.
The values that operators are applied to are called
operands
Basic Arithmetic Operators:
The following operators perform basic
arithmetic operations:
+ : Addition
- : Subtraction
* : Multiplication
/ : Division
** : Exponentiation
Division in
Python:
In Python 3.x, the
division
operator / results
in a floating point
In Python 2.x, dividing two integers would truncate the
number:
result to an integer:
To achieve integer
division in Python
3.x, use the floored
division
operator //:
In the previous sections you've seen examples with basic
arithmetics. In the following table you can see the most common
arithmetic operators in Python, with examples:
Order of Operations in Python
In Python, the order of operations follows the standard mathematical rules,
often remembered by the acronym PEMDAS:
Parentheses
Exponents
Multiplication and Division (from left to right)
Addition and Subtraction (from left to right)
This means that calculations within parentheses are performed first,
followed by exponents, then multiplication and division, and finally
addition and subtraction.