At its highest level, the Python interpreter's job is to execute programs,
composed of statements. However, much of the interesting work of computation
comes from evaluating expressions. Statements govern the relationship among
different expressions in a program and what happens to their results.
If you want to change selection, open document below and click on "Move attachment"
1.5 Controlgt;> def square(x):
return mul(x, x)
Sometimes it does make sense to have a function whose body is an expression,
when a non-pure function like print is called.
>>> def print_square(x):
print(square(x))
<span>At its highest level, the Python interpreter's job is to execute programs,
composed of statements. However, much of the interesting work of computation
comes from evaluating expressions. Statements govern the relationship among
different expressions in a program and what happens to their results.
1.5.2 Compound Statements
In general, Python code is a sequence of statements. A simple statement is a
single line that doesn't end in a colon. A compound statement is so call Summary
status | not read | | reprioritisations | |
---|
last reprioritisation on | | | suggested re-reading day | |
---|
started reading on | | | finished reading on | |
---|
Details