Skip to main content

Operator's in Python पायथन में ऑपरेटर्स

Python supports various types of operators for performing operations on variables and values. Here are some common types of operators in Python:
पायथन वेरिएबल्स और मानों पर संचालन करने के लिए विभिन्न प्रकार के ऑपरेटरों का समर्थन करता है। यहां पायथन में कुछ सामान्य प्रकार के ऑपरेटर हैं:

1. Arithmetic Operators:

   + # Addition 
   - # Subtraction
   * # Multiplication
   / # Division
   % # Modulus (remainder)
   ** # Exponentiation
   // # Floor Division

2. Comparison Operators:
   
   == # Equal to
   != # Not equal to
   < # Less than
   > # Greater than
   <= # Less than or equal to
   >= # Greater than or equal to
   

3. Logical Operators:
  
   and # Logical AND
   or # Logical OR
   not # Logical NOT
  

4. Assignment Operators:
  
   = # Assignment
   += # Add and assign
   -= # Subtract and assign
   *= # Multiply and assign
   /= # Divide and assign
   
5. Identity Operators:
   
   is # Returns True if both variables are the same object
   is not # Returns True if both variables are not the same object
   

6. Membership Operators:
   
   in # Returns True if a value is present in a sequence
   not in # Returns True if a value is not present in a sequence
   
These operators allow you to perform a wide range of operations in Python. 
ये ऑपरेटर आपको पायथन में कई प्रकार के ऑपरेशन करने की अनुमति देते हैं।

In Python, operators have different precedence levels, which determine the order in which operations are performed in an expression. Understanding operator precedence helps in avoiding ambiguity and clarifying the order of operations in complex expressions. Here's a general overview of operator precedence, from highest to lowest:
पायथन में, ऑपरेटरों के पास अलग-अलग प्राथमिकता स्तर होते हैं, जो किसी अभिव्यक्ति में संचालन के क्रम को निर्धारित करते हैं। ऑपरेटर प्राथमिकता को समझने से अस्पष्टता से बचने और जटिल अभिव्यक्तियों में संचालन के क्रम को स्पष्ट करने में मदद मिलती है। यहां उच्चतम से निम्नतम तक ऑपरेटर प्राथमिकता का सामान्य अवलोकन दिया गया है:

1. Parentheses ( )

2. Exponentiation **

3. Unary Operators: unary plus +x , unary minus -x , bitwise NOT ~x

4. Multiplication *, Division /, Modulus %

5. Addition + , Subtraction -

6. Bitwise Left Shift Operator<< , Bitwise Right Shift Operator >> 

7. Bitwise AND &

8. Bitwise XOR ^

9. Bitwise OR |

10. Comparison Operators
    == , !=, <, >, <=, >=

11. Logical NOT not

12. Logical AND and

13. Logical OR or

14. Conditional Expression (Ternary Operator)
    x if condition else y

15. Assignment Operators
    =, +=, -=, *=, /=, etc

Comments

Popular posts from this blog

Filter function of python

filter function:-  Imagine we have a bunch of things, like a list of numbers, a collection of fruits, or any other group of items. Now, let's say we want to pick out only certain items from that group based on a specific condition. This is where the filter function comes in handy. Let's say we have a list of numbers, and we want to filter out only the even numbers. We define a condition-checking function that checks if a number is even. Then, we pass this function and the list of numbers to the filter function. It goes through each number, applies the condition-checking function, and keeps only the numbers that are even. Finally, it gives us a new list containing only the even numbers. def is_even(num):     return num % 2 == 0 numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] filtered_numbers = list(filter(is_even, numbers)) print(filtered_numbers) Output [2, 4, 6, 8, 10] We can also utilize lambda expressions to define filtering conditions directly within the filter function. nu...

The Python Interpreter पायथन इंटरप्रेटर

The Python interpreter is a program that executes Python code. It reads and interprets Python scripts or interactive commands, converting them into machine-readable bytecode for the computer to execute.The interpreter is a crucial component for running Python code, facilitating both learning and development processes. Users can interact with the interpreter in two primary modes: पायथन इंटरप्रेटर एक प्रोग्राम है जो पायथन कोड को निष्पादित करता है। यह पायथन स्क्रिप्ट या इंटरैक्टिव कमांड को पढ़ता है और व्याख्या करता है, उन्हें कंप्यूटर द्वारा निष्पादित करने के लिए मशीन-पठनीय बाइटकोड में परिवर्तित करता है। दुभाषिया पायथन कोड चलाने के लिए एक महत्वपूर्ण घटक है, जो सीखने और विकास दोनों प्रक्रियाओं को सुविधाजनक बनाता है। उपयोगकर्ता इंटरप्रेटर के साथ दो प्राथमिक मोड में बातचीत कर सकते हैं:- 1. Interactive Mode:- In this mode we can launch the Python interpreter in our terminal or command prompt without specifying a script.This mode allows us to enter Python commands and see immediate results...

Lambda Function of Python पायथन में लैम्ब्डा फ़ंक्शंस

Lambda functions, also known as anonymous functions that are one-line functions without a name. They are defined using the lambda keyword and are primarily used when a small function is required for a short period. Lambda functions can take any number of arguments but can only have a single expression. लैम्ब्डा फ़ंक्शंस, जिन्हें अनाम फ़ंक्शंस के रूप में भी जाना जाता है, जो बिना नाम के एक-पंक्ति फ़ंक्शंस हैं। उन्हें लैम्ब्डा कीवर्ड का उपयोग करके परिभाषित किया गया है और मुख्य रूप से तब उपयोग किया जाता है जब छोटी अवधि के लिए एक छोटे फ़ंक्शन की आवश्यकता होती है। लैम्ब्डा फ़ंक्शंस किसी भी संख्या में तर्क ले सकते हैं लेकिन केवल एक ही अभिव्यक्ति हो सकती है। Syntax:- lambda arguments: expression Example:- double = lambda x: x * 2 print(double(5))  #Output=10 sum = lambda a, b: a + b print(sum(3, 4))  #Output=7