Python Tutorial 07
Python Operators
In Python, operators are special symbols or characters that are used to perform operations on variables, values, or expressions. Python provides a wide range of operators that serve different purposes. Here are the main categories of operators in Python:
Arithmetic Operators:
Arithmetic operators are used to perform mathematical operations like addition, subtraction, multiplication, division, modulus, and exponentiation.
Addition: '+'
Subtraction: '-'
Multiplication: '*'
Division: '/'
Modulus (remainder): '%'
Exponentiation: '**'
Floor Division (quotient): '//'
Python Programming Tutorial 07 | Python Operators |
Assignment operators:
Assignment operators are used to assign values to variables.
Assignment: '='
Add and Assign: '+='
Subtract and Assign: '-='
Multiply and Assign: '*='
Divide and Assign: '/='
Modulus and Assign: '%='
Exponentiate and Assign: '**='
Floor Divide and Assign: '//='
Python Programming Tutorial 07 | Python Operato |
Comparison Operators:
Comparison operators are used to compare values and return a Boolean result (True or False).
Equal to: '=='
Not equal to: '!='
Greater than: '>'
Less than: '<'
Greater than or equal to: '>='
Less than or equal to: '<='
Python Programming Tutorial 07 | Python Operators |
Logical Operators:
Logical operators are used to combine or manipulate Boolean values.
Logical AND: 'and'
Logical OR: 'or'
Logical NOT: 'not'
Python Programming Tutorial 07 | Python Operator |
Bitwise Operators:
Bitwise operators perform operations on individual bits of binary numbers.
Bitwise AND: '&'
Bitwise OR: '|'
Bitwise XOR: '^'
Bitwise NOT: '~'
Left shift: '<<'
Right shift: '>>'
Python Programming Tutorial 07 | Python Operators |
Membership Operators:
Membership operators are used to test if a value is a member of a sequence or collection.
'in': Returns True if a value is found in the sequence.
'not in': Returns True if a value is not found in the sequence.
Python Programming Tutorial 07 | Python Operators |
Identity Operators:
Identity operators are used to compare the memory locations of two objects.
'is': Returns True if two variables refer to the same object.
'is not': Returns True if two variables refer to different objects.
Python Programming Tutorial 07 | Python Operators |
0 comments:
Post a Comment