Dev ❤ Ops

What are Operators in Python

In Python, operators are special symbols that represent calculations like addition, multiplication, and comparison. Here’s a list of the most common operators in Python:

Arithmetic operators
  • +: Addition
  • -: Subtraction
  • *: Multiplication
  • /: Division
  • %: Modulus (remainder after division)
  • **: Exponentiation
  • //: Floor division (division that results in a whole number)
Comparison operators
  • ==: Equal to
  • !=: Not equal to
  • >: Greater than
  • <: Less than
  • >=: Greater than or equal to
  • <=: Less than or equal to
Logical operators
  • and: True if both operands are true
  • or: True if either operand is true
  • not: True if the operand is false
Assignment operators
  • =: Assign a value to a variable
  • +=: Add a value to a variable and assign the result to the variable
  • -=: Subtract a value from a variable and assign the result to the variable
  • *=: Multiply a variable by a value and assign the result to the variable
  • /=: Divide a variable by a value and assign the result to the variable
  • %=: Calculate the modulus of a variable and a value and assign the result to the variable
  • **=: Raise a variable to the power of a value and assign the result to the variable
  • //=: Calculate the floor division of a variable and a value and assign the result to the variable

For more information please visit python.org

This article is created based on experience but If you discover any corrections or enhancements, please write a comment in the comment section or email us at contribute@devopsforu.com. You can also reach out to us from Contact-Us Page.

Follow us on LinkedIn for updates!

Leave a comment

Your email address will not be published. Required fields are marked *