Search⌘ K
AI Features

Operators

Explore the role of operators in programming, including arithmetic, relational, and logical types. Understand how to use them to perform calculations and comparisons, which are essential skills for writing effective code.

Operators

Previously, we discussed how a statement is made up of expressions and that expressions can be made up of operations or operands.

Let’s see an example of this. Here, we’ll create two variables and assign a value to each of them. Then, we’ll add the two values together and store the result in a new variable:

Python
number1 = 10
number2 = 15
result = number1 + number2
print result

On line 1, we create a variable called number1 and assigned the value 10 to it. We now know that this means several things: ...