Python Full Course In Hindi

Home About Us Contact Us Privacy Policy
drthh

Operators

operators वे चिहन होते है | जिनके उपयोग से varriables और values पर operations किए जाते है | सरल शब्दो मे values पर operations perform करने के लिए operators का उपयोग किया जाता है | +,-,= इतयादि कुछ operators है |

  • Arithmetic Operators
  • mahtematics operations करने के लिए arithematics operators ka उपयोग किया जाता है | arithematics operators numerical values पर काम करते है |

    Operators operators Sign example Output
    Addition + a + b 13
    substraction - a - b -3
    multiplication * a - b 40
    division / a - b 0.625



  • Works
  • Addition = >value को आपस मे जोडने के लिए Addition operator का उपयोग किया जाता है |
    substraction= >एक value मे से दूसरी को minus करने के लिए substraction operator का उपयोग किया जाता है |
    multiplication = >values को आपस मे multiply करने के लिए multiplication operator का उपयोग किया जाता है |
    division = >एक value से दूसरी को भाग देने के लिए division operator का उपयोग किया जाता है |

    🐍 Syntax
    a = 1 b = 8 print(a+b) print(a-b) print(a*b) print(a/b)
    Output
    9
    -7
    8
    0.125
    
  • Comparison Operators
  • Comparison operators को relational operators के नाम से भी जाना जाता है | किन्ही values की आपस मे तुलना (compare) करने के लिए Comparison operators का उपयोग किया जाता है |

    Operators Operators Sign examples Output
    equal equal == a == b False
    Not Equal != a != b True
    Greaterthan > a > b False
    lessthan << /td> a < b True
    Greaterthan equal >= a >= b False
    lessthan equal <=< /td> a <= b True
  • Works
  • double equal(= =) => a b के बराबर है | या नही ये पता करने के लिए | = = का उपयोग किया जाता है |
    not equal(! =) => a b के के बराबर नही है | ये पता करने के लिए | ! = का उपयोग किया जाता है |
    Greaterthan(>)=>a b से बडा है | ये पता करने के लिए | > का उपयोग किया जाता है |
    lessthan => a b से छोटा है | ये पता करने के लिए | < का उपयोग किया जाता है |
    Greaterthan equal (>=) => a b ke बराबर है | या a b से बडा है | पता करने के लिए >= का उपयोग किया जाता है |
    lessthan equal(<=) => a b के बराबर है | या a b से छोटा है | पता करने के लिए <= का उपयोग किया जाता है |
    🐍 Syntax
    a = 5 b = 9 print(a == b) print(a > b) print(a < b) print(a >= b) print(a <= b)
    Output
    False
    False
    True 
    False
    True 
    

    NOTE :

    ये a और b varriables name है | a और b की जगह कोई भी varriable Name हो सकता है |
  • Logical Operators
  • Operators example Output
    AND a==b and a!=b and a>b False
    Or a==b or a!=b or a>b True
    Not not a!=b False
    And = > and के case मे सभी conditions सही होने पर output True और False मे मिलता है |
    Or = > सभी conditions मे से कोई एक condition भी True होने पर output True मे मिलता है |
    Not = > का उपयोग करने पर condition उल्टी हो जाती है |


    🐍 Syntax
    a = 20 b = 10 print(a==b and a!=b and a>b) print(a==b and a!=b or a>b) print(not a!=b)
    Output
    False
    True
    False

    Assigement Operators

    varriables के अन्दर value assign करने के लिए Assigement operators का उपयोग किया जाता है|
    सरल शब्दो मे
    किसी varriable के अन्दर value assign करने के लिए कोई दुसरा varriable बनाने की जरुरत ना पडे इसलिए assigement operator का उपयोग किया जाता है |

    Operators examples Output
    = x = 10; 10
    += x + 5; 15
    -= x - 2; 8
    *= x * 3; 30
    /= x / 2; 5


  • Works
  • += => operator का उपयोग किसी varriable के अन्दर और value जोडने के लिए किया जाता है |
    -= => किसी varriable के अन्दर से values कम के लिए किया जाता है | -=operator का उपयोग किया जाता है |
    *= => कोई value multiply करके किसी varriable के अन्दर stored value मे जोडने लिए *= का किया जाता है |
    /= => किसी varriable के अन्दर stored value को किसी और value से devide करने के लिए /= का उपयोग किया जाता है |

    🐍 Syntax
    a = 20 print(a+5) print(a-3) print(a*2) print(a/3)
    Output
    25
    17
    40
    6.666666666666667

    Membership Operators

    कोई alphabet,number etc. किसी list,dictionary etc. के अन्दर है | या नही ये पता करने के लिए Membership Operator का उपयोग किया जाता है |

    🐍 Syntax
    a = "hello" print('h' in a)
    Output
    True