Open main menu

CDOT Wiki β

Changes

OPS435 Python Lab 3

1 byte removed, 14:35, 30 May 2017
INVESTIGATION 1: USING FUNCTIONS
= INVESTIGATION 1: USING FUNCTIONS =
:A very simple definition of using '''functions''' is like having '''smaller programs contained inside a larger program''' that can be run by '''function name''' to perform '''repeated or commonly routine tasks'''. Usually, the function will contain programming code in some part of the main program (By calling the function by name to run code that is already stored in internal memory prevents the program from repeating the entry of repetitive code, thus reducing the size of the program and making it execute more efficiently. When creating programs that define and use functions, '''a large programming task can be broken-down into smaller elements''' (or '''modules'''). This is why creating programs that use functions is referred to as '''modular programming'''.
:In our situation, a Python '''function''' is a '''predefined set of code''', this code is loaded into python (eg. internal memory), but it does not immediately perform any actions. Functions may accept arguments and/or return values, or not accept arguments and/or return values. Until a Function is specifically told to execute, it's code will sit (in internal memory) unused.
13,420
edits