-
Hajipur, Bihar, 844101
Hajipur, Bihar, 844101
Introduction to Python
Python Basics
Python Syntax
Python Comments
Python Variables
Python Data Types
Python Casting
Python I/O
Python Operators
Cotrol Structures
Data Structures
Python Strings
Python Lists
Python Tuples
Python Dictionaries
Python Sets
Python Arrays
Python Bytes and Bytearray
Date and Time
Functions and Module
File Handling
Python OOP
Advanced Concepts
Python Scope
Python Modules
Python JSON
Python RegEx
Python PIP
Python Try...Except
Python String Formatting
Python User Input
Python VirtualEnv
Python Math
Python DSA
Python DSA
Lists and Arrays
Python Stacks
Python Queues
Linked Lists
Python Hash Tables
Python Trees
Python Binary Trees
Binary Search Trees
Python AVL Trees
Python Graphs
Searching Algorithms
Sorting Algorithms
Operators are special symbols in Python used to perform operations on variables and values.
For example, +
is an operator used to add two values.
Python provides several types of operators:
Type | Example Operators |
---|---|
Arithmetic | + , - , * , / , // , % , ** |
Assignment | = , += , -= , *= , /= , etc. |
Comparison | == , != , > , < , >= , <= |
Logical | and , or , not |
Identity | is , is not |
Membership | in , not in |
Bitwise | & , ` |
Operator | Meaning |
---|---|
+ |
Addition |
- |
Subtraction |
* |
Multiplication |
/ |
Division |
// |
Floor Division |
% |
Modulus |
** |
Exponentiation |
Used to assign values to variables:
=
, +=
, -=
, *=
, /=
, %=
, //=
, **=
, etc.
Example:
x = 10
x += 5 # Now x becomes 15
Used to compare two values and return True
or False
.
Operator | Meaning |
---|---|
== |
Equal to |
!= |
Not equal to |
> |
Greater than |
< |
Less than |
>= |
Greater or equal |
<= |
Less or equal |
Used to combine conditional statements.
Operator | Description |
---|---|
and |
True if both are true |
or |
True if at least one is true |
not |
Reverses the result |
Used to compare memory locations.
Operator | Meaning |
---|---|
is |
Returns True if both variables point to the same object |
is not |
Returns True if they do not |
Used to check if a value is in a sequence (list, string, etc.)
Operator | Meaning |
---|---|
in |
True if present |
not in |
True if not present |
Works on binary numbers.
Operator | Name |
---|---|
& |
AND |
` | ` |
^ |
XOR |
~ |
NOT |
<< |
Left Shift |
>> |
Right Shift |
Q1. Write a Python program to add two numbers using the +
operator.
Q2. Write a Python program to subtract one number from another using the -
operator.
Q3. Write a Python program to multiply two numbers using the *
operator.
Q4. Write a Python program to divide two numbers using both /
and //
operators and observe the difference in the output.
Q5. Write a Python program to use the **
operator to calculate the square of a number.
Q6. Write a Python program to check if two values are equal using the ==
operator.
Q7. Write a Python program to use the and
operator to check if two conditions are true.
Q8. Write a Python program to use the in
operator to check if a word exists in a string.
Q9. Write a Python program to use the is
operator to check if two variables refer to the same object.
Q10. Write a Python program to perform bitwise AND on two integers using the &
operator.
Introduction to Python
Python Basics
Python Syntax
Python Comments
Python Variables
Python Data Types
Python Casting
Python I/O
Python Operators
Cotrol Structures
Data Structures
Python Strings
Python Lists
Python Tuples
Python Dictionaries
Python Sets
Python Arrays
Python Bytes and Bytearray
Date and Time
Functions and Module
File Handling
Python OOP
Advanced Concepts
Python Scope
Python Modules
Python JSON
Python RegEx
Python PIP
Python Try...Except
Python String Formatting
Python User Input
Python VirtualEnv
Python Math
Python DSA
Python DSA
Lists and Arrays
Python Stacks
Python Queues
Linked Lists
Python Hash Tables
Python Trees
Python Binary Trees
Binary Search Trees
Python AVL Trees
Python Graphs
Searching Algorithms
Sorting Algorithms