Operators

887
Python-Operators

Python Operators क्या हैं?

Operators का use हम बचपन से करते आ रहे हैं जैसे कोई भी दो संख्याओं को जोड़ना वहाँ पर + (Plus) operator का use करते थे लेकिन programming भाषा में कई operators का use किया जाता है। Python में Operator एक special symbol है जो कि arithmetic और logical ऑपरेशन के लिये use होता है। और वह वैल्यू जिस पर ऑपरेटर कार्य (operate) करते है उन्हें operands कहते है। Operators का प्रयोग प्रोग्राम में data तथा variables को manipulate करने के लिए किया जाता है.

python operators दो प्रकार के होते है:- unary operators तथा binary operators.

unary operator केवल एक operand पर operate होता है. जबकि binary operator दो operands पर operate होता है.

उदाहरण के लिए:- 6+8, जहाँ 6 तथा 8 operands है जबकि + एक ऑपरेटर है.

types of python operators in hindi:-

python operators निम्नलिखित होते है:-

1:- arithmetic operator

2:- relational (comparison) operator

3:- logical operator

4:- bitwise operator

5:- assignment operator

6:- identity operator

7:- membership operator

1:- arithmetic operators:-

arithmetic operators का प्रयोग गणितीय कार्यों को करने के लिए किया जाता है जैसे:- addition, substraction, division आदि.

यहाँ पर हमने उदाहरण के लिए वेरिएबल x का मान 20 तथा y का मान 30 लिया है.

operators description Example
+ (addition) यह दो operands को जोड़ता है. x + y = 50
– (substraction) यह दो operands को घटाता है. x – y = -10
* (multipication) यह दो operands को गुणा करता है x * y = 600
/ (division) यह right वाले operands से left वाले operands को divide करता है y / x = 1.5
% (modulus) यह right वाले operand से left वाले operand को divide करता है तथा यह शेषफल return करता है. y * x = 0
// (floor division) यह right वाले operands से left वाले operands को divide करता है तथा भागफल return करता है. यह दशमलव वाले हिस्से को छोड़ देता है जैसे:- 13//3 = 4 तथा 15//2 = 7
** (exponential) इसमें right वाला operand, left वाले operand की power (घात) बन जाता है. x ** y (x to the power y) माना x = 2, y =4 तो x ** y = 16

2:- relational (comparison) operators:-

रिलेशनल ऑपरेटर का प्रयोग दो values को compare करने के लिए किया जाता है. यह condition के अनुसार या तो true return करता है या false.
यहाँ पर हमने उदाहरण के लिए वेरिएबल x की वैल्यू 20 तथा y की वैल्यू 30 दी है.

operators description Example
== यदि दोनों operands की वैल्यू समान होती है तो condition सत्य होती है. (x == y) सत्य नहीं है.
!= यदि दोनों operands की वैल्यू समान नहीं होती है तो condition सत्य होती है. (x != y) सत्य है
< > यदि दोनों operands की वैल्यू समान नहीं होती है तो condition सत्य होती है. यह != की तरह है. (x < > y) सत्य है
> यदि left operand की वैल्यू right operand से बड़ी होती है तो condition सत्य होती है. (x > y) सत्य नही है.
< यदि right operand की वैल्यू left operand से बड़ी होती है तो condition सत्य होती है. (x < y) सत्य है.
>= यदि left operand की वैल्यू right operand से बड़ी होती है या बराबर होती है तो condition सत्य होती है (x >= y) सत्य नही है.
<= यदि right operand की वैल्यू left operand से बड़ी होती है या छोटी होती है तो condition सत्य होती है (x <= y) सत्य है.

3:- logical operators:-

लॉजिकल ऑपरेटर जो है वह Boolean expressions को compare करता है तथा Boolean result रिटर्न करता है.

operators description Example
and यदि दोनों operands सत्य होते है तो condition सत्य होती है. 6>3 and 5<10 सत्य है
or यदि दो operands में से एक भी सत्य होता है तो condition सत्य होती है. 6>3 or 5>10 सत्य है
not यदि operands की वैल्यू गलत होती है तो condition सत्य होती है. not(5 < 2) सत्य है

4:- bitwise operators:-

bitwise python operators जो है वह bits पर कार्य करते है तथा bit by bit ऑपरेशन को परफॉर्म करते है.

उदाहरण के लिए माना x = 10 तथा y = 4

तो बाइनरी फॉरमेट में x = 0000 1010 तथा y = 0000 0100

operators meaning Example
& bitwise AND x & y = 0 (0000 0000)
| bitwise OR x | y = 14 (0000 1110)
~ bitwise NOT ~ x = -11 (1111 0101)
^ bitwise XOR x ^ y = 14 (0000 1110)
>> Bitwise right shift x >> 2 = 2 (0000 0010)
<< Bitwise left shift x << 2 = 40 (0010 1000)

5:- assignment operators:-

python में assignment operators का प्रयोग variables को वैल्यू assign करने के लिए किया जाता है.

operators description Example same as
= यह बायीं तरफ के expression को वैल्यू assign करता है. x = 5 x = 5
+= यह right operand को left operand से जोड़ता है तथा जो result आता है उसे left operand को assign करता है. x += 5 x = x + 5
-= यह right operand को left operand में घटाता है तथा जो result आता है उसे left operand को assign करता है. x -= 5 x = x – 5
*= यह right operand को left operand में गुणा करता है तथा जो result आता है उसे left operand को assign करता है. x *= 5 x = x * 5
/= यह left operand को right operand से divide करता है तथा जो result आता है उसे left operand को assign करता है. x /= 5 x = x / 5
%= यह दो operands का modulus लेता है और उसे left operand को assign करता है. x %= 5 x = x % 5
**= यह operands में power (घात) को परफॉर्म करता है तथा उसे left operand को assign करता है. x **= 5 x = x ** 5
//= यह operators में floor division को परफॉर्म करता है तथा उसे left operand को assign करता है. x //= 5 x = x // 5

6:- identity operators:-

identity python operators दो ऑब्जेक्ट्स के मैमोरी लोकेशन को compare करता है.

operators description Example
is यदि दोनों operands एक ही जैसी identity साझा करते है तो condition सत्य होगी अन्यथा असत्य होगी. x is y
is not यदि दोनों operands एक ही जैसी identity साझा नहीं करते है तो condition सत्य होगी अन्यथा असत्य होगी. x is not y

7:- membership operators:-

membership python operators का प्रयोग sequence में membership को टेस्ट करने के लिए किया जाता है. sequence एक list, एक string या एक tuple हो सकती है. python में दो मेम्बरशिप ऑपरेटर है जो नीचे दिए गये है:-

operators description Example
in यदि ऑपरेटर के दोनों तरफ के वेरिएबल एक sequence में होते है तो condition सत्य होगी अन्यथा असत्य होगी. x in y
not in यदि ऑपरेटर के दोनों तरफ के वेरिएबल एक sequence में नहीं होते है तो condition सत्य होगी अन्यथा असत्य होगी. x not in y

 

The symbols that trigger the operation / action on data, are called operators. The operations (specific tasks) are represented by Operators and the objects of the operation (s) are referred to as Operands.

Arithmetic Operators

Symbol Name Example Result Comment
+ Addition 6+5

5+6

11

11

Adds values of its two operands.
Subtraction 6-5

5-6

 1

-1

Subtracts the value of right operand from left operand.
* Multiplication 5*6

6*5

30

30

Multiplies the values of its two operands.
/ Division 60/5 12 Divides the value of left operand with the value of right operand and returns the result as a float value.
% Modulus (pronounced mo-du-lo) or Remainder 60%5

6%5

0

1

Divides the two operands and gives the remainder resulting.
// Floor division 7.2 // 2 3.0 Divides and truncates the fractional part from the result.
** Exponentiation (Power) 2.5 ** 3 15.625 Returns base raised to power exponent. (2.53 here).

Python Programs के लिये यहाँ click करें।

C programs के लिये यहाँ click करें।

Operators in python define operators in python operator in python python operators python operator Python Operators in hindi operators in hindi