Logical Operator in Python
Logical operators in Python are used for conditional statements are true or false. Logical operators in Python are AND, OR and NOT.
पॉयथन में लॉजिकल ऑपरेटरों का उपयोग कंडीशनल स्टेटमेंट टू या फाल्स के लिए किया जाता है। पॉयथन में लॉजिकल ऑपरेटर AND, OR और NOT हैं।
1. and Operator: returns true only if both operands are true. In any other case, False will be returned
रिटर्न तभी टू होगा जब दोनों ऑपरेंड्स टू हों। किसी भी अन्य मामले में, फाल्स रिटर्न होगा।
For example:
>>> True & True True >>> True & False False >>> False & True False >>> False & False False
2. for Operator: Returns ‘False’ if both operands are ‘False’ otherwise returns ‘True’.
‘फाल्स’ रिटर्न होगा, यदि दोनो ऑपरेंड ‘फाल्स’ हैं, किसी भी अन्य मामले में ‘टू’ पर रिटर्न होगा।
For example:
>>> True | True True >>> True | False True >>> False | True True >>> False | False False
3. ‘not operator: Negates the truth value of a single operand. In other words, ‘True’ becomes ‘False’ and vice versa.
एक ही ऑपरेंड के टू वैल्यू को नकारता है। दूसरे शब्दों में, ‘टू’ ‘फाल्स’ हो जाता है और इसके विपरीत।
For Boolean Type Examples:
बूलियन टाइप के उदाहरण के लिए
>>>not True False >>>not False True >>>not 15 >13 False >>>not (15 >13 and 15 > 2) False >>>not (15 >13 and 15 < 33) False >>>not (15 <13 and 15 < 33) True
Bitwise Operators
बिटवाईस ऑपरेटर
Bitwise operators are used to perform bitwise calculations. These operators are applicable only for ‘int’ and ‘bool type only; if we are trying to apply for any other type then PVM gives an Error Message. In background, the integers are converted into binary format and then operations are performed bit by bit, hence the name “bitwise operators”. These operators are also called binary operators. Python bitwise operators work on integral values only and the final output is returned in the decimal format. Python bitwise operators are mostly used in mathematical calculations.
बिटवाइज ऑपरेटरों का उपयोग बिटवाईस गणना करने के लिए किया जाता है। ये ऑपरेटर केवल ‘int’ और ‘bool’ टाइप के लिए लागू होते हैं, अगर हम किसी अन्य प्रकार के लिए एप्लाई करने की कोशिश कर रहे हैं तो पीवीएम एक त्रुटि संदेश देता है। बैकग्राउंड में, इंटीजर, बाइनरी फार्मेट में परिवर्तित हो जाते हैं और फिर ऑपरेशन बिट द्वारा किया जाता है, इसलिए इसका नाम “बिटवाइज ऑपरेटर” है। इन ऑपरेटरों को बाइनरी ऑपरेटर भी कहा जाता है। पॉयथन बिटवाइस ऑपरेटर केवल इंटीग्रल वैल्यू पर काम करते हैं और अंतिम आउटपुट डेसीमल फार्मेट में दिया जाता है। पॉयथन बिटवाइस ऑपरेटरों का उपयोग ज्यादातर गणितीय गणनाओं में किया जाता है।
Operator Precedence
ऑपरेटर प्रेसीडेंस
In Python or other languages, the combination of values, variables, operators and function calls is termed as an expression.
पॉयथन में या अन्य भाषाओं में, वैल्यू, वैरियेबल, ऑपरेटरों और फंक्शन कॉल के संयोजन को एक एक्सप्रेशन के रूप में कहा जाता है।
Python interpreter can evaluate a valid expression. पॉयथन इंटरप्रेटर एक वैलिड एक्सप्रेशन का मूल्यांकन कर सकता है।
For example:
>>>16 – 20
-4
Here 16 – 20 is an expression. There can be more than one operator in an expression.
यहाँ 16-20 एक एक्सप्रेशन है। एक एक्सप्रेशन में एक से अधिक ऑपरेटर हो सकतें हैं।
To evaluate these types of expressions there is a rule of precedence in Python. It guides the order in which operation are carried out.
इस प्रकार के एक्सप्रेशन का मूल्यांकन करने के लिए पॉयथन में प्रेसीडेंस का नियम है। यह उस क्रम को निर्देशित करता है जिसमें ऑपरेशन किया जाता है।
For example: Multiplication has higher precedence than subtraction.
उदाहरण के लिए: गुणा में घटाने की तुलना में बड़ी प्रेसीडेंस होती है।
# Multiplication has higher precedence than subtraction Output: 2
# गुणा घटाने की तुलना में अधिक प्रेसीडेंस वाले होत है आउटपुट: 2
>>>10 – 4 * 2
2
But we can change this order using parentheses ( ) as it has higher precedence.
लेकिन हम कोष्ठक ) का उपयोग करके इस ऑर्डर को बदल सकते हैं क्योंकि इसकी ब्रेकेट की प्रेसीडेन्सी ज्यादा होती है।
For example:
>>> (10 – 4) * 2
12
Chapter wise Model Paper Link
- Introduction to Web Design
- Editors
- HTML Basics
- CSS
- CSS Framework
- JavaScript and Angular JS
- Photo Editor
- Web Publishing and Browsing