Types of Operators in Python with Examples

Master Python with 70+ Hands-on Projects and Get Job-ready - Learn Python

Program 1

#Aritmatical operator  + - * /  // %  ,**

# print(5*3)
# print(" Indore "*3)
# print(5**3)  
# n=int(input("Enter a number"))
# p=int(input("Enter a power"))
# print(n**p)
# print(15.0/2)  # 7.5
# print(15.0//2)  # 7.0
# print(15//2) 
# print(15%2)
n=int(input("Enter a number"))
if( n%2==0):
    print("No is even")
else:
    print("No is odd")

Program 2

#Relational operator
# > < >= <= == !=
# print(60>10)
# print(60>60)
# print(60>=60)
# print(10<60)
# print(60<60)
# print(60<=60)
#print(60==60)
# a=10
# b=30
# print(a==b)  
# print(a!=b) 
#conditional operator
 # if else
a=int(input("Enter First number"))
b=int(input("Enter Second number"))
c=int(input("Enter Third number"))
print("Grater No is:",a) if (a>b and a>c ) else  print("Grater No is: ",b) if(b>c) else print("Grater No is ",c)

Program 3

# Membership 
# in and not in
# str="Indore is my city and clean city"
# print("City"  not in str)
# email="[email protected]"
# print("Valid email id") if('@' in email) else print("Invalid email id")

# Bitwise
# & | ^ ~ << >>



Program 4

You give me 15 seconds I promise you best tutorials
Please share your happy experience on Google

courses
Image

DataFlair Team

DataFlair Team provides high-impact content on programming, Java, Python, C++, DSA, AI, ML, data Science, Android, Flutter, MERN, Web Development, and technology. We make complex concepts easy to grasp, helping learners of all levels succeed in their tech careers.

Leave a Reply

Your email address will not be published. Required fields are marked *