the exits with in the parenthesis
function
variable
argument
formula
Answers
How to Think Like a Computer Scientist: Learning with Python 2nd Edition documentation »
3. Functions
3.1. Definitions and use¶
In the context of programming, a function is a named sequence of statements that performs a desired operation. This operation is specified in a function definition. In Python, the syntax for a function definition is:
You can make up any names you want for the functions you create, except that you can’t use a name that is a Python keyword. The list of parameters specifies what information, if any, you have to provide in order to use the new function.
There can be any number of statements inside the function, but they have to be indented from the def. In the examples in this book, we will use the standard indentation of four spaces. Function definitions are the first of several compound statements we will see, all of which have the same pattern:
A header, which begins with a keyword and ends with a colon.
A body consisting of one or more Python statements, each indented the same amount – 4 spaces is the Python standard – from the header.
In a function definition, the keyword in the header is def, which is followed by the name of the function and a list of parameters enclosed in parentheses. The parameter list may be empty, or it may contain any number of parameters. In either case, the parentheses are required.
The first couple of functions we are going to write have no parameters, so the syntax looks like this:
def new_line():
print # a print statement with no arguments prints a new line
This function is named new_line. The empty parentheses indicate that it has no parameters. Its body contains only a single statement, which outputs a newline character. (That’s what happens when you use a print command without any arguments.)
Defining a new function does not make the function run. To do that we need a function call. Function calls contain the name of the function being executed followed by a list of values, called arguments, which are assigned to the parameters in the function definition. Our first examples have an empty parameter list, so the function calls do not take any arguments. Notice, however, that the parentheses are required in the function call:
i hope it's helpful to u ❤