Parentheses Expression:-
Parentheses को हिंदी में कोष्ठक कहा जाता है। Programming में इन्हें () symbols से लिखा जाता है। Expression में parentheses का मुख्य उद्देश्य किसी calculation या condition को group करना और उसके evaluation order को control करना है।
English:
Parentheses are represented by (). In programming, they are mainly used to group expressions and control the order in which an expression is evaluated.
📌 Rule 1: Highest Precedence — सबसे पहली प्राथमिकता
English: Parentheses () have the highest priority in an expression. The expression inside parentheses is evaluated first.
Hindi: Parentheses () की expression में सबसे अधिक प्राथमिकता होती है। इनके अंदर का expression पहले evaluate होता है।
क्योंकि पहले multiplication होगा:
Parentheses के साथ:
पहले addition होगा:
याद रखें:
👉 Parentheses के अंदर का काम पहले।
📌 Rule 2: Innermost First — सबसे अंदर वाला पहले
English: In nested parentheses, Python evaluates the innermost parentheses first and then moves outward.
Hindi: Nested parentheses में Python सबसे पहले अंदर वाले parentheses को evaluate करता है और फिर बाहर की तरफ आता है।
Step-by-step:
Answer: 28
Another Example
Answer: 48
📌 Rule 3: Parentheses Change Evaluation Order Parentheses Evaluation Order बदल सकते हैं
English: Parentheses can change the normal order in which operators are evaluated.
Hindi: Parentheses operators के सामान्य evaluation order को बदल सकते हैं।
Example: Subtraction
Normally subtraction is evaluated left-to-right:
लेकिन:
👉 इसलिए parentheses expression का result बदल सकते हैं।
📌 Rule 4: Grouping — Expression को Group करना
English: Parentheses are used to group parts of an expression and make the intended calculation clear.
Hindi: Parentheses expression के अलग-अलग parts को group करने और calculation को clear बनाने के लिए उपयोग किए जाते हैं।
Calculation:
Benefits / लाभ:
📌 Rule 5: Logical Operators के साथ
English: Parentheses can change the order of logical operations.
Logical operators में सामान्य priority होती है:
Python में सामान्य logical precedence:
Example:
पहले and:
अब parentheses:
👉 Parentheses logical expression का evaluation order बदल सकते हैं।