Hướng dẫn assignment operators in python

Operators are used to perform operations on values and variables. These are the special symbols that carry out arithmetic, logical, bitwise computations. The value the operator operates on is known as Operand.

Here, we will cover Assignment Operators in Python. So, Assignment Operators are used to assigning values to variables. 

Operator

Description

Syntax

=

Assign value of right side of expression to left side operand x = y + z 

+=

Add and Assign: Add right side operand with left side operand and then assign to left operand a += b   

-=

Subtract AND: Subtract right operand from left operand and then assign to left operand: True if both operands are equal a -= b  

*=

Multiply AND: Multiply right operand with left operand and then assign to left operand a *= b     

/=

Divide AND: Divide left operand with right operand and then assign to left operand a /= b

%=

Modulus AND: Takes modulus using left and right operands and assign result to left operand a %= b  

//=

Divide[floor] AND: Divide left operand with right operand and then assign the value[floor] to left operand a //= b   

**=

Exponent AND: Calculate exponent[raise power] value using operands and assign value to left operand a **= b     

&=

Performs Bitwise AND on operands and assign value to left operand a &= b   

|=

Performs Bitwise OR on operands and assign value to left operand a |= b    

^=

Performs Bitwise xOR on operands and assign value to left operand a ^= b    

>>=

Performs Bitwise right shift on operands and assign value to left operand a >>= b     

= b

print[a]

Output:

0

 13] Bitwise Left Shift and Assign: This operator is used to perform Bitwise left shift on the operands and then assigning result to the left operand.

Syntax:

x 

Chủ Đề