Boolean Operators in Python
เคเคจ เคเคชเคฐेเคเคฐ्เคธ เคा เคเคชเคฏोเค เคเคฎ्เคชाเคंเคก เคंเคกीเคถเคจ्เคธ (เคเค เคถเคฐ्เคค เคो เคฆो เคฏा เค เคงिเค เคถเคฐ्เคคों เคो เคฎिเคฒाเคเคฐ เคฌเคจा เคนो) เคो เคฌเคจाเคจे เคे เคฒिเค เคिเคฏा เคाเคคा เคนै। เคเคฌ เคฌूเคฒिเคฏเคจ เคเคชเคฐेเคเคฐ्เคธ เคฌूเคฒ เคाเคเคช เคे เคฎाเคจ เคैเคธे True เคฏा False เคชเคฐ เคเคชเคฐेเคถเคจ เคเคฐเคคे เคนैं เคคो เคฌूเคฒ เคाเคเคช เคा เคฐिเคเคฒ्เค เคฆेเคคे เคนैं।
เคเคจ เคเคชเคฐेเคเคฐ्เคธ เคा เคเคชเคฏोเค เคเคฎ्เคชाเคंเคก เคंเคกीเคถเคจ्เคธ (เคเค เคถเคฐ्เคค เคो เคฆो เคฏा เค เคงिเค เคถเคฐ्เคคों เคो เคฎिเคฒाเคเคฐ เคฌเคจा เคนो) เคो เคฌเคจाเคจे เคे เคฒिเค เคिเคฏा เคाเคคा เคนै। เคเคฌ เคฌूเคฒिเคฏเคจ เคเคชเคฐेเคเคฐ्เคธ เคฌूเคฒ เคाเคเคช เคे เคฎाเคจ เคैเคธे 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 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 )
Logical And (and):-
เคฏเคน เคเคชเคฐेเคเคฐ เคฆोเคจों เคธाเคเคก เคी เคตैเคฒ्เคฏू เคे True เคนोเคจे เคชเคฐ เคชเคฐिเคฃाเคฎ True เคฆेเคคा เคนै เค เคจ्เคฏเคฅा False เคฆेเคคा เคนै। เคชाเคฏเคฅเคจ เคฎें, เคฒॉเคिเคเคฒ AND เคเคชเคฐेเคเคฐ เคो `and` เคฆ्เคตाเคฐा เคฆเคฐ्เคถाเคฏा เคाเคคा เคนै। เคเคธเคा เคเคชเคฏोเค เคฆो เคฏा เคฆो เคธे เค เคงिเค เคถเคฐ्เคคों เคो เคธंเคฏुเค्เคค เคเคฐเคจे เคे เคฒिเค เคिเคฏा เคाเคคा เคนै, เคเคฐ เคฏเคฆि เคธเคญी เคถเคฐ्เคคें 'เคธเคนी' เคชเคฐ เคฎूเคฒ्เคฏांเคเคจ เคเคฐเคคी เคนैं, เคคो เคฏเคน 'เคธเคนी' เคฒौเคाเคคा เคนै, เค เคจ्เคฏเคฅा, เคฏเคน 'เคเคฒเคค' เคฒौเคाเคคा เคนै। เคเคช เค เคชเคจे เคोเคก เคฎें เค เคงिเค เคเคिเคฒ เคธ्เคฅिเคคिเคฏाँ เคฌเคจाเคจे เคे เคฒिเค `and` เคเคชเคฐेเคเคฐ เคा เคเคชเคฏोเค เคเคฐ เคธเคเคคे เคนैं, เคตिเคถेเคท เคฐूเคช เคธे เคธเคถเคฐ्เคค เคเคฅเคจों เคฎें (เคเคฆाเคนเคฐเคฃ เคे เคฒिเค, เคฏเคฆि เคเคฅเคจ) เคฏा เค เคชเคจे เคช्เคฐोเค्เคฐाเคฎो เคฎें เคจिเคฐ्เคฃเคฏ เคฒेเคคे เคธเคฎเคฏ।
- `True and True` เคा เคฎूเคฒ्เคฏांเคเคจ `True` เคธे เคนोเคคा เคนै।
- `True and False` เคा เคฎूเคฒ्เคฏांเคเคจ `False` เคธे เคนोเคคा เคนै।
- `False and True` เคा เคฎूเคฒ्เคฏांเคเคจ `False` เคธे เคนोเคคा เคนै।
- `False and False` เคा เคฎूเคฒ्เคฏांเคเคจ `False` เคธे เคนोเคคा เคนै।
This operator returns True if the values on both sides are True, otherwise it returns False. In Python, the logical AND operator is denoted by `and`. It is used to combine two or more conditions or expressions, and it returns `True` if all of the conditions or expressions evaluate to `True`, otherwise, it returns `False`. You can use the `and` operator to create more complex conditions in your code, especially in conditional statements (e.g., if statements) or while making decisions in your programs.
Here's how the `and` operator works:
- `True and True` evaluates to `True`.
- `True and False` evaluates to `False`.
- `False and True` evaluates to `False`.
- `False and False` evaluates to `False`.
If the value of both the sides of this operator is not in Boolean values (True / False) then they work in the other way. As-
เคฏเคฆि x False เคนै เคคो เคชเคฐिเคฃाเคฎ y เคนोเคा เค
เคจ्เคฏเคฅा เคชเคฐिเคฃाเคฎ x เคนोเคा ।
If x is False then the result will be y otherwise the result will be
x.
Logical Or (or):-
เคฏเคน เคเคชเคฐेเคเคฐ เคฆोเคจों เคธाเคเคก เคी เคตैเคฒ्เคฏू เคे False เคนोเคจे เคชเคฐ เคชเคฐिเคฃाเคฎ False เคฆेเคคा เคนै เค เคจ्เคฏเคฅा True เคฆेเคคा เคนै। เคชाเคฏเคฅเคจ เคฎें, เคฒॉเคिเคเคฒ OR เคเคชเคฐेเคเคฐ เคो เคीเคตเคฐ्เคก `or` เคฆ्เคตाเคฐा เคฆเคฐ्เคถाเคฏा เคाเคคा เคนै। เคเคธเคा เคเคชเคฏोเค เคฆो เคฏा เคฆो เคธे เค เคงिเค เคถเคฐ्เคคों เคो เคธंเคฏोเคिเคค เคเคฐเคจे เคे เคฒिเค เคिเคฏा เคाเคคा เคนै เคเคฐ เคฏเคฆि เคเคฎ เคธे เคเคฎ เคเค เคถเคฐ्เคค 'True' เคนै เคคो 'True' เคฒौเคाเคคा เคนै। เคฏเคฆि เคธเคญी เคถเคฐ्เคคें `เคเคฒเคค` เคนैं, เคคो เคฏเคน `False` เคฒौเคाเคคा เคนै।
This operator returns False if both sides of the value are False, otherwise it returns True. In Python, the logical OR operator is represented by the keyword `or`. It is used to combine two or more conditions and returns `True` if at least one of the conditions is `True`. If all the conditions are `False`, it returns `False`.
If the value of both the sides of this operator is not in Boolean values (True / False) then they work in the other way. As-
Logical Not (not):-
เคฏเคน เคเค เคฏूเคจเคฐी เคเคชเคฐेเคเคฐ เคนै เคो เคธिंเคเคฒ เคตैเคฒ्เคฏू เคชเคฐ เคाเคฐ्เคฏ เคเคฐเคคा เคนै เคคเคฅा True เคो False เคฎें เคคเคฅा False เคो True เคฎें เคฌเคฆเคฒเคคा เคนै। เคชाเคฏเคฅเคจ เคฎें, เคฒॉเคिเคเคฒ NOT เคเคชเคฐेเคเคฐ เคो เคीเคตเคฐ्เคก `not` เคฆ्เคตाเคฐा เคฆเคฐ्เคถाเคฏा เคाเคคा เคนै। เคเคธเคा เคเคชเคฏोเค เคฌूเคฒिเคฏเคจ เคเค्เคธเคช्เคฐेเคถเคจ เคे เคคाเคฐ्เคिเค เคฎाเคจ เคो เคเคฒเคเคจे เคे เคฒिเค เคिเคฏा เคाเคคा เคนै। เคเคฌ เคเคช เคฌूเคฒिเคฏเคจ เคฎाเคจ เคฏा เคเค्เคธเคช्เคฐेเคถเคจ เคชเคฐ `not` เคฒाเคू เคเคฐเคคे เคนैं, เคคो เคฏเคน เคตिเคชเคฐीเคค เคฎाเคจ เคฒौเคाเคเคा। เคฏเคฆि เคเค्เคธเคช्เคฐेเคถเคจ 'True' เคนै, เคคो 'not' เคเคธे 'False' เคฌเคจा เคฆेเคा, เคเคฐ เคฏเคฆि เคเค्เคธเคช्เคฐेเคถเคจ 'False' เคนै, เคคो 'not' เคเคธे 'True' เคฌเคจा เคฆेเคा। `not` เคเคชเคฐेเคเคฐ เคธเคถเคฐ्เคค เคฌเคฏाเคจों, เคฒूเคช เคเคฐ เค เคจ्เคฏ เคจिเคฏंเคค्เคฐเคฃ เคธंเคฐเคเคจाเคं เคฎें เคธ्เคฅिเคคिเคฏों เคो เคจเคाเคฐเคจे เคे เคฒिเค เคเคชเคฏोเคी เคนै।
It is a unary operator which operates on a single value and converts True to False and False to True. In Python, the logical NOT operator is represented by the keyword `not`. It is used to reverse the logical value of a Boolean expression. When you apply `not` to a Boolean value or expression, it will return the opposite value. If the expression is `True`, `not` will make it `False`, and if the expression is `False`, `not` will make it `True`. The `not` operator is useful for negating conditions in conditional statements, loops, and other control structures.

Thanks sir๐
ReplyDeleteWelcome.. ๐
Delete