In this article, let's talk about the assignment operator in the python operator, and hopefully this article will give you some help in learning about Python.
Assignment operators:
The following assumes that the variable A is 10 and the variable B is 20:
= Simple assignment operator C = A + B assigns the result of the operation of A + B to the C + + assignment operator C + = A is equivalent to C = c + a = subtraction assignment operator C = A The equivalent of C = c-a *= multiplication assignment operator C *= A is equivalent to C = c * A /= division assignment operator C/= A is equivalent to C = c/a %= Fetch The modulo assignment operator C%= A is equivalent to C = c% A **= power assignment operator C **= A is equivalent to C = c * * A //= take the divisible assignment operator C//= A is equivalent to c = c//A
Some of the commonly used assignment operators are written above, using the assignment operator to illustrate some examples:
#!/usr/bin/python#-*-coding:utf-8-*-a = 21b = 10c = 0 c = a + Bprint "1-c value is:", c c + = Aprint "2-c value is:", c
c *= aprint "3-c value is:", c c /= a print "4-c value is:", c C = 2c%= Aprint "5-c value is:", c C **= aprint "6-c The value is: ", c C//= aprint" The value of 7-c is: ", C
The answers to the above examples are as follows:
The value of 1-C is: The value of 312-C is: The value of 523-C is: The value of 10924-C is: 525-c value is: 26-c value is: 99864
The assignment operator in the Python operator is not difficult to understand, as long as you try to give some more examples to experiment and believe it will be mastered soon, hopefully this article will help you to learn python.