Python Arithmetic, Relational, and Logical Operators

Special Symbols and Representing Values

Kurtis Pykes
Geek Culture

--

The Python Logo from Python.org

Operators are special symbols that carry out various computations in Python. We apply operators to operands to create an expression. Expressions are simply representations of values.

Python has several built-in operators, but in this article, we will only focus on arithmetic, relational, and logical operators.

Table of Contents 
--> Understanding operators and expressions
--> Aritmetic operators
--> Relational operators
--> Mind the gotcha
--> Logical operators
--> and
--> not
--> or
--> Order of precedence

Understanding operators & expressions

Operators are used to inform Python that we want to perform some computation. For example, if we want to add two numbers together in Python we would do the following:

>>> 2+5
7

The operator in the code cell above is the plus sign (+); The values that our operator is acting upon are known as operands. We’ve used literal values as an operand but we can use an identifier to reference the integer object instead.

>>> a = 2
>>> b = 5
>>> a + b
7

--

--

Kurtis Pykes
Geek Culture

I ghostwrite Educational Email Courses for high-ticket B2B service founders. https://www.thesocialceoblueprint.com/