You could then use the find/replace function in your editor to change all of the 50s to 75s, but there is a good chance that you might miss one. Even worse, if this code were part of a much larger section, you might accidentally change a 50 that has nothing to do with this change.

So, if you needed to change the size of your squares from 50 to 75, instead of having to go through and change all of the 50s to 75s, you can just change length = 50 to length = 75 and instantly make all of the needed changes.

This picture shows the name length being taken from the 50 object and placed on the 75 object.

这幅图片展示了变量 length 如何从 50转变到 75的。

它现在是多少？What Was That Again?

Once you have created variables, you will want to be able to see and to use the values they are holding on to. In the interactive session, you can just mention the name again, and the interpreter will tell you what it is.

Notice here that there are a few different types of values that your variable names can be attached to.

注意在这里只能有少数不同类型的值可以赋予给你的变量。

'Ford Fairlane' is a string -- a series of characters enclosed in quotes. 1700 is an integer with nothing after the decimal point. 23.4 is called a floating point number -- it can have a fractional value, and notice that the value stored may not be exactly what you specified. True and False are available as boolean values.

Sometimes it is helpful to have more than one name for things. For instance, if you get tired of typing out pete.forward all the time, you could do:

有时有不止一种方法能够达到同样的效果。例如当你厌倦输入 pete.forward 时，你可以：

forward = pete.forward

and then even:

甚至：

fd = forward

(Note that there are no parenthesis at the end of any of the names.)

（注意这里的名字后面都没有圆括号。）

Now, instead of using pete.forward(20), you could just say fd(20)

现在，代替pete.forward(20)， 你可以只输入fd(20)

Of course, forward(20) and pete.forward(20) still work too. An object can have as many names or aliases as you would like to give it.

当然， forward(20) 和 pete.forward(20) 仍然可以运行。一件事物可以有许多你喜欢的名字或者别名。

Here the method object pete.forward has been given many different names: forward, fd and foo.

在这里，方法pete.forward 被赋予了许多不同的名字： forward，fd 和foo。

好名字Good Names

Making short names -- like using fd for pete.forward -- can save you a lot of time and typing when working in the interactive interpreter.

用一个简短的名字 -- 就像用 fd 代替 pete.forward -- 可以在使用交互环境的时候为你节省很多时间和输入内容。

However, when you start creating longer programs, you need to balance two things: You do not want to not type too much, but also you need to be able to remember what a particular name refers to.

任何时候，当你要创建一个比较长的程序时，你需要均衡两件事：你不想键入太多的内容，同时你也希望记住一项名字代表的内容。

Generally, unless a name will only be mentioned in one small area, you should not use names like:

通常，除非这个名字在一个很小的区域使用，你最好不要用像这样的名字：

a
i
q

since it is just too difficult to understand what they mean.

这样的话就非常难理解名字代表什么意思。

Instead, think about what the names refer to, and use names like:

替代的做法是，想一下这个名字代表什么意思，然后这样来用：

number_of_apples
appleindex
quitAppleGame

Notice that there are a few different styles used to name things.

注意这里有一些不同的风格用在名字上。

You should read through some other people's code and choose a style that you like, then try to use the same style consistently in all of your code.

你可以通过阅读别人的代码然后选择一种你喜欢的命名风格，并在你所有的代码中总是运用这种相同的风格。

一点数学知识A Little Math

Sometimes you do not know exactly what you want to store in a variable, but you could calculate it from other values that you do know. Just use mathematical symbols, and Python will do the calculations for you.