Learn python functions, arguments, scopes, return values, modules and libraries with progate

python progate learning course Ⅲ

function

argument

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) **

scope

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.

Return value

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

module

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 ()".

Library

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

Learn python functions, arguments, scopes, return values, modules and libraries with progate
[Python for Hikari-] <Supplement> Chapter 06-05 Functions (arguments and return values 4)
[Python for Hikari-] Chapter 06-04 Functions (arguments and return value 3)
[Python for Hikari-] Chapter 06-03 Functions (arguments and return value 2)
Use Python and MeCab with Azure Functions
Julia Quick Note [22] Calling Python functions and Python modules
Getting Started with python3 # 2 Learn about types and variables
Learn Python with ChemTHEATER
Python packages and modules
This and that for using Step Functions with CDK + Python
Curry arbitrary functions with Python ....
Programming with Python and Tkinter
Encryption and decryption with Python
Python and hardware-Using RS232C with Python-
Understand Python packages and modules
Install external libraries with Python
Keyword arguments for Python functions
python with pyenv and venv
Python 3 sorted and comparison functions
Python higher-order functions and comprehensions
Works with Python and R