Python Oprater

                       Rajeev Ranjan Tiwari


Python Operators

Operators are used to perform operations on variables and values.

Python divides the operators in the following groups:

  • Arithmetic operators
  • Assignment operators
  • Comparison operators
  • Logical operators
  • Identity operators
  • Membership operators
  • Bitwise operators

(1)
 x = 5
y = 3

print(x + y)

(2)
x = 5
y = 3

print(x - y)

(3)
x = 5
y = 3

print(x * y)

(4)
x = 12
y = 3

print(x / y)

(5)
x = 5
y = 2

print(x % y)

(6)
x = 2
y = 5

print(x ** y)  #same as 2*2*2*2*2

(7)

x = 15
y = 2

print(x // y)

#the floor division // rounds the result down to the nearest whole number


Python Assignment Operators

Assignment operators are used to assign values to variables:

(1)

x = 5

print(x)

(2)
x = 5

x += 3

print(x)

(3)
x = 5

x -= 3

print(x)

(4)
x = 5

x *= 3

print(x)

(5)
x = 5

x /= 3

print(x)

(6)
x = 5

x//=3

print(x)

(7)
x = 5

x//=3

print(x)

(8)
x = 5

x **= 3

print(x)

(9)
x = 5

x &= 3

print(x)

(10
x = 5

x <<= 3

print(x)


Python Comparison Operators

Comparison operators are used to compare two values:

(1)

x = 5

y = 3

print(x == y)

# returns False because 5 is not equal to 3


(2)

x = 5
y = 3

print(x != y)

# returns True because 5 is not equal to 3

(3) x = 5
y = 3

print(x > y)

# returns True because 5 is lgreater than 3

(4)
x = 5
y = 3

print(x > y)

# returns True because 5 is greater than 3

(5) x = 5
y = 3

print(x >= y)

# returns True because five is greater, or equal, 



अंत मे अगर इस पोस्ट से आपको कुछ फायदा हुवा हो तो इसे दुसरो के साथ भी share करे ताकी दुसरो का भी फायदा हो. इस पोस्ट को पूरा पढ़ने के लिए आपका धन्यवाद और बहुत शुक्रिया.
Thanks friend posted by Rajeev Ranjan Tiwari

Comments

Post a Comment

Popular posts from this blog

OT Technician

D Pharma

Tor Browser