Operators

Arithmetic Operators

🙋 Need help? Ask an expert now!

Operations on variables and values

Operators are used to perform operations on variables and values.

This means that you can use the operators to manipulate variables in the same way that we talked about in the last lecture.

Python divides the operators in the following groups:

  • Arithmetic operators
  • Assignment operators
  • Comparison operators
  • Logical operators
  • Identity operators
  • Membership operators

Types of Arithmetic Operators

Here I will introduce these operators, and also provide the space for you to create variables and play with these operations. Linked to each topic is a wiki article describing the functionality.

Addition: x + y

Subtraction: x - y

Multiplication x * y

Division: x / y

Modulus: x % y

Exponentiation: x ** y

Floor division: x // y

            
# Example: Declare variables and multiply them x = 10 y = 5 print(x + y)