The argument is this value that you pass to the function when you call it. If you pass an argument, you can use the value in the function and change the value according to the value. To pass an argument to a function, specify a variable (formal argument) that will be a box to put the argument. To pass arguments to a function, call it as ** function name (argument) **
A variable has a range in which the variable can be used, and this range is scoped. The scope of variables defined in formal parameters and functions is only in functions
In order for the function to receive multiple arguments, define the formal arguments separated by commas (,). The arguments are called "first argument, second argument ..." in order from the left. To pass multiple arguments, they must be in the same order as the corresponding formal arguments
Initial value can be set for the argument When the argument is omitted, the initial value is used as an alternative value if the initial value is given.
When you want to use the processing result of a function in the caller of the function Use return in a function to return the return value to the caller ** return Return value ** retuan terminates the processing in the function, so the processing after return is not executed You can use multiple returns using conditional branching
A module is a file in which Python code is written. You can use the code written there by reading another file as a module. Modules can be loaded using ** import ** You can load the module by writing "import module name" in the file you want to use. The loaded module can execute the function in the module by writing "module name.function name ()".
Pre-prepared modules are called ** standard library ** Let the computer get it randomly using the randam module function randint By writing ** random.randint (x, y) **, you can randomly get an integer from x to y.
Recommended Posts