How to use assignment operator in Python
Python how to use the assignment operator, many novices are not very clear about this, in order to help you solve this problem, the following editor will explain for you in detail, people with this need can come to learn, I hope you can gain something.
Code implementation
A = 10print ('1, a =', a) a = a + 5print ('2, a =', a) a + = 5print ('3, a =', a) a-= 5print ('4, a =', a) a * = 5print ('5, a =', a) a * * = 2print ('6, a =', a) a / = 25print ('7, a =', a) a = 25.0# when performing arithmetic operations on floating point numbers The result also returns a floating point number print ('8, a =', a) a / / = 5print ('9, a =', a) a = 5print ('10, a =', a) a% = 4print ('11, a =', a)
Code run output:
1. A = 10
2. A = 15
3. A = 20
4. A = 15
5. A = 75
6. A = 5625
7, a = 225.0
8, a = 25.0
9, a = 5.0
10, a = 5
11, a = 1
Program analysis
# in this example, the main example is the assignment operator, which can be found in any program, which is very basic knowledge, and there are many forms to follow, but there are also rules to follow. This part lists some of the main forms. Please practice more in your daily study and work.
# = you can assign the value to the right of the equal sign to the variable to the left of the equal sign
# + = a + = 5 equals a = a + 5
#-= a-= 5 is equivalent to a = a-5
# * = a * = 5 equals a = a * 5
# * = a * * = 5 equals a = a * * 5
# / = a / = 5 is equivalent to a = a / 5
# / / = a / / = 5 is equivalent to a = a / / 5
#% = a% = 5 equals a = a% 5
Is it helpful for you to read the above content? If you want to know more about the relevant knowledge or read more related articles, please follow the industry information channel, thank you for your support.