Python Operators || operators in python, python operators in hindi

Home 👉 O level 👉 Python 👉 Unit 4


 Python Operators

एक ऑपरेटर एक प्रतीक (या चिन्ह) है जो एक ऑपरेशन (या कार्य) करता है।

An operator is a symbol (or sign) that performs an operation (or action).

    यदि कोई ऑपरेटर एकल ऑब्जेक्ट या मान पर कार्य करता है, तो उसे यूनरी (unary) ऑपरेटर कहा जाता है। यदि कोई ऑपरेटर दो ऑब्जेक्ट या मानों पर कार्य करता है, तो उसे बाइनरी (binary) ऑपरेटर कहते हैं। यदि कोई ऑपरेटर तीन ऑब्जेक्ट या मानों पर कार्य करता है, तो उसे टरनरी (ternary) ऑपरेटर कहते हैं।

    If an operator operates on a single object or value, it is called a unary operator. If an operator operates on two objects or values, it is called a binary operator. If an operator operates on three objects or values, it is called a ternary operator.

 Types

  • Arithmetic Operators
  • Comparison (Relational) Operators
  • Boolean (Logical) Operators
  • Bitwise Operators
  • Assignment Operators
  • Membership Operators
  • Identity Operators

 Arithmetic Operators:-

   इन ऑपरेटरों का उपयोग सामान्य अंकगणितीय गणनाएं जैसे जोड़, गुणा आदि करने के लिए किया जाता है। अंकगणित ओपेरटर वे चिन्ह हैं जिनका उपयोग गणित और प्रोग्रामिंग में संख्याओं या वेरिएबल्स पर बेसिक गणितीय कार्य करने के लिए किया जाता है। कंप्यूटर प्रोग्रामिंग में, इन ऑपरेटरों का उपयोग संख्यात्मक मानों में बदलाव करने के लिए किया जाता है। ये ऑपरेटर गणितीय गणना करने में मौलिक हैं और पायथन, सी, जावा और अन्य प्रोग्रामिंग भाषाओं में व्यापक रूप से उपयोग किए जाते हैं।

    These operators are used to perform common arithmetic calculations like addition, multiplication etc. Arithmetic operators are symbols or characters used in mathematics and programming to perform basic mathematical operations on numbers or variables. In computer programming, these operators are used to manipulate numeric values. These operators are fundamental in performing mathematical calculations and are widely used in programming languages like Python, C, Java, and more.


  • Exponentiation ( ** )
  • Multiplication ( * )
  • Division ( / )
  • Floor (Integer) Division ( // )
  • Modulus ( % )
  • Addition ( + )
  • Subtraction ( - )

 Arithmetic operators in detail


Comparison Operators:-

     ये बाइनरी ऑपरेटर्स हैं जो दो मानों की तुलना करते हैं और True या False में परिणाम देते हैं। तुलना ऑपरेटर, जिन्हें रिलेशनल ऑपरेटर के रूप में भी जाना जाता है, का उपयोग प्रोग्रामिंग में दो मानों की तुलना करने के लिए किया जाता है। वे तुलना के आधार पर एक बूलियन परिणाम (या तो 'सही' या 'गलत') लौटाते हैं। इन तुलना ऑपरेटरों का उपयोग अक्सर सशर्त बयानों, लूपों और अन्य नियंत्रण संरचनाओं में निर्णय लेने और मूल्यों या वेरिएबल्स के बीच संबंधों के आधार पर प्रोग्राम के प्रवाह को नियंत्रित करने के लिए किया जाता है।

    These are binary operators that compare two values and result in True or False. Comparison operators, also known as relational operators, are used in programming to compare two values or expressions. They return a Boolean result (either `True` or `False`) based on the comparison. These comparison operators are often used in conditional statements, loops, and other control structures to make decisions and control the flow of a program based on the relationships between values or variables.

  • Less Than ( < )
  • Less Than or Equals To ( <= )
  • Greater Than ( > )
  • Greater Than or Equals To ( >= )
  • Equals To ( == )
  • Not Equals To ( != )

Comparison Operators in detail


Boolean (Logical) Operators:-

    इन ऑपरेटर्स का उपयोग कम्पाउंड कंडीशन्स (एक शर्त जो दो या अधिक शर्तों को मिलाकर बना हो) को बनाने के लिए किया जाता है। जब बूलियन ऑपरेटर्स बूल टाइप के मान जैसे True या False पर ऑपरेशन करते हैं तो बूल टाइप का रिजल्ट देते हैं। पायथन में बूलियन ऑपरेटरों का उपयोग बूलियन मानों (सही और गलत) पर तार्किक क्रियाएं करने के लिए किया जाता है। पायथन में तीन मुख्य बूलियन ऑपरेटर हैं: `और`, `या`, और `नहीं`। इन बूलियन ऑपरेटरों का उपयोग अक्सर सशर्त बयानों, लूपों और अन्य स्थितियों में किया जाता है जहां आपको कुछ शर्तों की सच्चाई या झूठ के आधार पर निर्णय लेने की आवश्यकता होती है। वे आपके पायथन प्रोग्रामो में अधिक जटिल और सार्थक तर्क बनाने में आपकी सहायता करते हैं।

    These operators are used to create compound conditions (a condition made up of two or more conditions). Boolean operators return a result of bool type when they operate on values of bool type, such as True or False. Boolean operators in Python are used to perform logical operations on boolean values (True and False). Python has three main boolean operators: `and`, `or`, and `not`. These boolean operators are often used in conditional statements, loops, and other situations where you need to make decisions based on the truth or falsity of certain conditions. They help you create more complex and meaningful logic in your Python programs.

  • Logical And ( and )
  • Logical Or ( or )
  • Logical Not ( not )

Boolean Operators in detail


Bitwise Operators:-

    ये ऑपरेटर्स बिट्स पर ऑपरेशन करते हैं।  मानों को पहले बाइनरी में बदला जाता है फिर कैलकुलेशन किया जाता है। ये ऑपरेटर्स केवल इन्टिजर मानों पर कार्य करते हैं। पायथन में बिटवाइज़ ऑपरेटर आपको पूर्णांक मानों के बिट्स में हेरफेर करने की अनुमति देते हैं। इन ऑपरेटरों का उपयोग अक्सर निम्न-स्तरीय प्रोग्रामिंग में किया जाता है और बाइनरी डेटा के साथ काम करते समय या बिट-स्तरीय संचालन को शामिल करने वाले कुछ अल्गोरिथम को लागू करते समय विशेष रूप से उपयोगी होते हैं। बिटवाइज ऑपरेटरों का उपयोग तब किया जाता है जब आपको डेटा के बाइनरी प्रतिनिधित्व के साथ काम करने की आवश्यकता होती है या जब आप निम्न-स्तरीय बिट हेरफेर करना चाहते हैं। वे अक्सर कंप्यूटर हार्डवेयर, डेटा कम्प्रेशन, एन्क्रिप्शन और बहुत कुछ से संबंधित अनुप्रयोगों में देखे जाते हैं।

    These operators operate on bits. The values are first converted to binary then the calculations are done. These operators work only on integer values. Bitwise operators in Python allow you to manipulate individual bits of integer values. These operators are often used in low-level programming and are particularly useful when working with binary data or implementing certain algorithms that involve bit-level operations. Bitwise operators are used when you need to work with the binary representation of data or when you want to perform low-level bit manipulation. They are often seen in applications related to computer hardware, data compression, encryption, and more.

  • Bitwise AND ( & )
  • Bitwise OR ( | )
  • Bitwise XOR ( ^ )
  • Bitwise NOT ( ~ )
  • Bitwise Left Shift ( << )
  • Bitwise Right Shift ( >> )


Assignment Operator ( = ):-

    यह ऑपरेटर दाएं साइड के मान को बाएं साइड के वेरिएबल में स्टोर करता है। पायथन में असाइनमेंट ऑपरेटरों का उपयोग वेरिएबल्स में मान रखने के लिए किया जाता है। वे किसी मान के असाइनमेंट को गणितीय ऑपरेशन या अन्य ऑपरेशन के साथ जोड़ते हैं। ये असाइनमेंट ऑपरेटर एक ही चरण में ऑपरेशन करते समय वेरिएबल्स को उनके वर्तमान मूल्यों के आधार पर अपडेट करने का एक संक्षिप्त तरीका प्रदान करते हैं।

    This operator stores the value of the right side in the variable on the left side. Assignment operators in Python are used to assign values to variables. They combine the assignment of a value with a mathematical operation or other operations. These assignment operators provide a concise way to update variables based on their current values while performing an operation in a single step.

syntax: variable = value

example: x = 5

hint: stores value 5 in variable x

 

Membership Operators:-

    ये ऑपरेटर्स किसी मान को किसी मानों के समूह जैसे string या list में   खोजते हैं और मान के मिलने या न मिलने पर True या False में परिणाम देते हैं। पायथन में मेम्बरशिप ऑपरेटरों का उपयोग यह परीक्षण करने के लिए किया जाता है कि कोई मान या एलिमेंट किसी ग्रुप (सीक्वेंस) का सदस्य है, जैसे स्ट्रिंग, सूची या टपल। मेम्बरशिप ऑपरेटरों का उपयोग अक्सर सशर्त बयानों और लूपों में किया जाता है ताकि यह जांचा जा सके कि कोई एलिमेंट उस स्थिति के आधार पर विशिष्ट कार्रवाई करने से पहले ग्रुप (सीक्वेंस) में मौजूद है या नहीं।

    These operators search for a value in a set of values such as a string or list and return True or False if the value is found or not found. Membership operators in Python are used to test whether a value or element is a member of a sequence, such as a string, list, or tuple. Membership operators are often used in conditional statements and loops to check if an element is present in a collection before taking specific actions based on that condition.

  • In Membership ( in )

  • Not In Membership ( not in )


Identity Operators:-

    ये ऑपरेटर्स ऑब्जेक्ट्स की आइडेंटिटी (मेमोरी एड्रेस) को चेक करते हैं और समान होने या न होने के आधार पर True या False में परिणाम देते हैं। पायथन में, आइडेंटिटी ऑपरेटरों का उपयोग यह निर्धारित करने के लिए किया जाता है कि क्या दो वेरिएबल या ऑब्जेक्ट एक ही मेमोरी स्थान को संदर्भित (दर्शाते) करते हैं या एक ही पहचान रखते हैं। आइडेंटिटी ऑपरेटरों का उपयोग अक्सर ऑब्जेक्ट की तुलना करने और यह जांचने के लिए किया जाता है कि क्या वे एक ही उदाहरण हैं, खासकर जब लिस्ट, डिक्शनरी और यूजर-डिफाइंड क्लासेज जैसी परिवर्तनशील ऑब्जेक्ट से निपटते हैं। ध्यान रखें कि ये ऑपरेटर पहचान की जाँच करते हैं, समानता की नहीं। दो ऑब्जेक्ट मूल्य में समान हो सकती हैं लेकिन उनकी पहचान समान नहीं हो सकती।

    These operators check the identity (memory address) of the objects and return True or False depending on whether they are equal or not. In Python, identity operators are used to determine if two variables or objects reference the same memory location or have the same identity. Identity operators are often used to compare objects and check if they are the same instance, especially when dealing with mutable objects like lists, dictionaries, and user-defined classes. Keep in mind that these operators check for identity, not equality. Two objects can be equal in value but not have the same identity.

  • Is Identitical ( is )

  • Is Not Identitical ( is not )




---END---

Comments