Home > Article > Backend Development > How to assign value in python
How to assign values in python?
Python assignment method:
First, we need to open the python software, as shown in the figure:
Related recommendations: "Python Tutorial》
Now we will introduce some assignment methods that we often used before. The assignment symbol is "=", as shown in the figure:
Then we introduce the sequence unpacking and assignment method. Sequence unpacking is a method of performing multiple assignment operations at the same time: unpack the sequence of multiple values and then put them into the sequence of variables, as shown in the figure:
Let’s introduce the method of chain assignment. Chain assignment is to assign the same value to multiple variables, which is a bit like parallel assignment, as shown in the figure:
Finally, we introduce the method of incremental assignment. Incremental assignment is to express a variable and then reassign it to the variable, such as x=x 1, for example:
Notes
When unpacking the sequence, the number of variables on the left side of the assignment symbol is exactly the same as the number of elements in the sequence.
The so-called incremental assignment is for " *", "/", "%" and other standard operators are established
The above is the detailed content of How to assign value in python. For more information, please follow other related articles on the PHP Chinese website!