Doc print print each case the result the value the variable
2.3 Variable names and keywords | 13 | |
---|---|---|
message |
|
|
n | ||
pi |
>>> print n
17
>>> print pi
3.14159
In each case the result is the value of the variable. Variables also have types; again, we can ask the interpreter what they are.
Variable names can be arbitrarily long. They can contain both letters and num-bers, but they have to begin with a letter. Although it is legal to use uppercase letters, by convention we don’t. If you do, remember that case matters. Bruce and bruce are different variables.
The underscore character ( ) can appear in a name. It is often used in names with multiple words, such as my name or price of tea in china.
14 | Variables, expressions and statements |
---|
Python has twenty-eight keywords:
and |
|
import | raise | |||
---|---|---|---|---|---|---|
assert |
|
|
return | |||
break | global |
|
|
try | ||
class | finally | lambda | while |
A statement is an instruction that the Python interpreter can execute. We have seen two kinds of statements: print and assignment.
When you type a statement on the command line, Python executes it and displays the result, if there is one. The result of a print statement is a value. Assignment statements don’t produce a result.
1
2
Again, the assignment statement produces no output.