0% found this document useful (0 votes)
11 views7 pages

Operators

Operating systems

Uploaded by

M. B
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
0% found this document useful (0 votes)
11 views7 pages

Operators

Operating systems

Uploaded by

M. B
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
You are on page 1/ 7
Arithmetic operators: An arithmetic operator performs mathematical operations like addition, subtraction, division and multiplication. Operator Meaning Example + Add two operands >>>54+4 9 - Subtract two operands >>>6-4 2 - Multiply two operands >>>2*10 20 7 divide the left oferend by right operand | >>>5/2 2.5 % which will give us remindar part >>>5%3 2 w which will give integer part >>>5//3 1 * raised to the power >>>5"*3 125 Comparisons operator Operator | Description Example If two operands values are equal, then the | >>> condition becomes true. False = Values of two operands are not equal, then | >>>5S!=3 condition becomes true. True > If the value of left operand is greater than | >>>4>3 the value of right operand, then condition | True becomes true. < Tf the value of left operand is less than the | >>>6<4 value of right operand, then condition | False becomes true. cs greater than equal: If the value of left| >>>5>=6 operand is greater than or equal to the value | False of right operand, then condition becomes true. less thane >>>4<=6 True Logical operators * Logical operators is Boolean expressions such as and, or, not. ¢ Itis just a conditional test that a result is either True or False. operator | Description Example And it two operands are true it|}>>> True and True become true True >>>False and = True False Or it two operands are non-zero|>>>True or False | then condition becomes true. True | >>>False or False! False Not ‘Tit is used to reverse the logical | >>>not True | state of its operand. False | ‘ >>>not not not True L ae | Assignment operator: Operator Description Example Assigns values from right side operands to left side operand >>>x=20 += Tt adds right operand to the left operand and assign the result to left operand >>>x+=20 Tt subtracts right operand from the left operand and assign the result to left operand >>>x-=20 Tt multiplies right operand with the left operand and assign the result to left operand >>>x*=50 It divides left operand with the right operand and assign the result to left operand >3>x/=50 Tt takes modulus using two operands and assign the result to left operand >>>K%=50 Performs exponential (power) calculation on operators and assign value to the left operand >>>x**=50 Tt performs floor division on operators and assign value to the left operand >>>x//=50 Membership operator operator Description Example in Evaluates to true if it finds a| >>>x="python” variable in the specified sequence | >>>‘p’ in x and false otherwise. True not in Evaluates to true if it does not| >>>x="python” finds a variable in the specified | >>>'z’ in x sequence and false otherwise. False Bitwise operators Operator | Description Example >>>10&20 Operator copies a bit to the result & if it exists in both operands 0 | It copies a bit if it exists in either >>>10|20 operand. 30 a It copies the bit if it is set in one} >>>10%20 ~ | operand but not both. 30 A = It is unary and has the effect of | >>>~20 ‘flipping’ bits. -24 << The left operands value is moved left by the number of bits specified >>>10<<2 by the right operand. 40 >> The left operands value is moved >>>10>>2 right by the number of bits specified by the right operand, 2 on either side of the operator point >>>y="hello” Identity operators | Operator | Description Example is Evaluates to true if the variables | >>>x="hello” | on either side of the operator point | >>>y="hello” | to the same object and false| >>>x is y | otherwise. True is not Evaluates to false if the variables | >>>x="hello” | | to the same object and true otherwise. >>>x is not y False L

You might also like