0% found this document useful (0 votes)
36 views2 pages

Python Operators Explained

The document provides examples of various operators in Python, including arithmetic, bitwise, identity, membership, and the ternary operator. It demonstrates how to perform operations such as addition, modulus, and logical comparisons. Additionally, it includes examples of checking even or odd numbers using a conditional expression.

Uploaded by

Vipin Yadav
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
36 views2 pages

Python Operators Explained

The document provides examples of various operators in Python, including arithmetic, bitwise, identity, membership, and the ternary operator. It demonstrates how to perform operations such as addition, modulus, and logical comparisons. Additionally, it includes examples of checking even or odd numbers using a conditional expression.

Uploaded by

Vipin Yadav
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

# learning operators

var=10
print(var)
print(type(var))
var1=10.5
print(var1)

a=10
b=2
r=a+b
r-=b
r%=b
print("mod is",r)

print(True or False)

#bitwise operators
a=10
b=4
print(~a)
print(a>>2)
print(a<<2)
print(a ^ b)
print(a & b)
print(a | b)

# identity operators is is not


l=[1,2,3]
l2=[1,2,3]
l3=l
print(l is not l3)
# membership operators in not in
x=3
print(x not in l3)

name="Python"

print('Pyt' not in name)


"""
"""# Ternary operator
#min= if_true_value if condition else if_false_value

a=2
b=4
large= a if a>=b else b
print(large)

# check if number is even or odd


num=2001
result="even" if num%2==0 else "Odd"
print("the number is "+result)

You might also like