Читать книгу Introduction to Python Programming for Business and Social Science Applications - Frederick Kaefer - Страница 59
User-Defined Functions
ОглавлениеWe have used small Python code examples up until this point to illustrate basic coding elements of Python. As Python programs become more complex and involve more lines of code, errors can be more difficult to identify, and the code can be more difficult to modify and to test. To address these issues, a programming best practice is to package code into small units, which are often one printed page or less. In Python, we accomplish this by placing portions of code into functions, which are subroutines of code developed to perform specific tasks.