B.Tech Students: Apply for Live Programming Internship C, C++, Java, Python ,Web page Designing, PHP Python Operators | LiveCodeProgramming

Python Operators

Operators in Python are special symbols used to perform operations on variables and values. For example: + adds, * multiplies, etc.

Python में operators वो symbols होते हैं जिनसे हम variables और values पर कोई operation करते हैं जैसे + जोड़ने के लिए, * गुणा के लिए।

Arithmetic Operators
a = 10
b = 3
print(a + b)  # Addition
print(a - b)  # Subtraction
print(a * b)  # Multiplication
print(a / b)  # Division
print(a % b)  # Modulus

Output:

13
7
30
3.3333333333333335
1

Performs basic arithmetic operations.

बेसिक गणितीय operations करता है जैसे जोड़, घटाव।

Comparison Operators
x = 5
y = 10
print(x > y)   # Greater than
print(x == y)  # Equal to
print(x != y)  # Not equal

Output:

False
False
True

Used to compare two values.

दो values की तुलना करने के लिए।

Assignment Operators
num = 10
num += 5
print(num)  # num = num + 5

Output:

15

Used to assign values to variables.

Variable को value assign करने के लिए।

Logical Operators
a = True
b = False
print(a and b)  # AND
print(a or b)   # OR
print(not a)    # NOT

Output:

False
True
False

Combines multiple conditions.

कई conditions को जोड़ने के लिए।

Identity Operators
x = [1, 2]
y = x
z = [1, 2]
print(x is y)  # True
print(x is z)  # False

Output:

True
False

Checks if two variables point to the same object.

दो variables एक ही object को point कर रहे हैं या नहीं, ये चेक करता है।

Membership Operators
lst = [1, 2, 3]
print(2 in lst)
print(4 not in lst)

Output:

True
True

Checks if a value is present in a sequence.

जांचता है कि value list या sequence में है या नहीं।