Home > Backend Development > Python Tutorial > How to assign value in python

How to assign value in python

藏色散人
Release: 2019-10-18 11:19:39
Original
21875 people have browsed it

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

How to assign value in python

Now we will introduce some assignment methods that we often used before. The assignment symbol is "=", as shown in the figure:

How to assign value in python

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:

How to assign value in python

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:

How to assign value in python

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:

How to assign value in python

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!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template