Home >Backend Development >Python Tutorial >How to implement multiplication between variables in Python

How to implement multiplication between variables in Python

不言
不言Original
2018-09-20 15:50:064965browse

The content of this article is about Python variables and how to implement multiplication operations between variables. It has certain reference value. Friends in need can refer to it. I hope it will be helpful to you.

Variables: Variables are used to store some intermediate results during program operation. To facilitate subsequent calls, the same variable can be reassigned.

Characteristics of variables: descriptive tags, stored in memory.

Let’s take a look at an example to briefly understand the variable multiplication operation:

x = 3
y = 9
z = x * y
print("3*9=",z)
print("z=",z)

As shown in the picture: left code, right interactor output result.

We pay attention to some things: the = sign here means assignment, that is, the right side is assigned to the left side, 3 is assigned to x, and the * sign represents the multiplication operator.

The following is about the naming method and precautions for variables.

Naming method of variable names:

1. Descriptive, that is, you can know what the variable expresses

2. It cannot be named in Chinese, although it is not An error will occur, but the character encoding method needs to be taken into account

3. Variable names can only be composed of _ (underscore), letters, and numbers, and other special characters cannot appear, eg: &*^%$#. ........

4. You cannot use spaces or numbers as the beginning of variables

5. Reserved characters cannot be used, that is, print, and other command characters

6. It is best not to start with a capital letter, because the constants are named in all capital letters for better distinction

The above is the detailed content of How to implement multiplication between variables in Python. For more information, please follow other related articles on the PHP Chinese website!

Statement:
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