Читать книгу Introduction to Python Programming for Business and Social Science Applications - Frederick Kaefer - Страница 63

Stop, Code, and Understand! SCU 2.7 Modify a User-Defined Function

Оглавление

Download the file “SCU 2_7.py” from the companion website and save it either on your computer or on a removable storage device. Open the file in the Python IDLE editor and modify the function “my_function” so it prints the average of x and y. Execute the modified program after the change to verify that the revised code runs and produces the correct result.

Description

Lessons learned: In this section, we learned about a few functions that Python already has defined and that one common use of built-in functions is converting object data types from one type to another. We also learned about user-defined functions and how functions can have arguments (values passed to them) as well as return values. We saw how we must be careful when specifying arguments when we call functions or else errors will result.

Introduction to Python Programming for Business and Social Science Applications

Подняться наверх