Skip to content

Latest commit

 

History

History
 
 

Day-06

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 

Introduction to Operators in Python

Operators in Python are special symbols or keywords that are used to perform operations on variables and values. Python supports a wide range of operators, categorized into several types. These operators allow you to perform tasks such as arithmetic calculations, assign values to variables, compare values, perform logical operations, and more.

Here are the main types of operators in Python:

  1. Arithmetic Operators: These operators are used for performing basic mathematical operations such as addition, subtraction, multiplication, division, and more.

  2. Assignment Operators: Assignment operators are used to assign values to variables. They include the equal sign (=) and various compound assignment operators.

  3. Relational Operators: Relational operators are used to compare values and determine the relationship between them. They return a Boolean result (True or False).

  4. Logical Operators: Logical operators are used to combine and manipulate Boolean values. They include "and," "or," and "not."

  5. Identity Operators: Identity operators are used to check if two variables point to the same object in memory. The identity operators in Python are "is" and "is not."

  6. Membership Operators: Membership operators are used to check if a value is present in a sequence or collection, such as a list, tuple, or string. The membership operators in Python are "in" and "not in."

  7. Bitwise Operators: Bitwise operators are used to perform operations on individual bits of binary numbers. They include bitwise AND, OR, XOR, and more.

  8. Precedence of Operations: Operators in Python have different levels of precedence, which determine the order in which operations are performed in an expression.