Operators in Python

Lesson 7/20 | Study Time: 15 Min
  • Operators are used to perform simple operations such as additions, comparisons etc on variables and values.
  • Python supports the following types of operators, we will be looking at some of the commonly used operators.

image.png

Arithmetic Operators

We can perform some basic arithmetic operations such as addition, subtraction, multiplication, etc. using Python.

Example:
x = 2
y = 3
x + y #addition
x * y #multiplicationSnapshot of basic arithmetic operations on notebook

Arithmetic Operators: Meanings & Examples

image.png


Comparison Operator

  • These are used to compare two values
  • Gives a Boolean result (True/False)
image.png


Comparison Operators: Meanings & Examples

image.png


Logical Operator

  • Logical operators are used to combine conditional statements
  • Gives a Boolean result (True/False)
image.png

image.png

GDPR

When you visit any of our websites, it may store or retrieve information on your browser, mostly in the form of cookies. This information might be about you, your preferences or your device and is mostly used to make the site work as you expect it to. The information does not usually directly identify you, but it can give you a more personalized web experience. Because we respect your right to privacy, you can choose not to allow some types of cookies. Click on the different category headings to find out more and manage your preferences. Please note, that blocking some types of cookies may impact your experience of the site and the services we are able to offer.