Open main menu

CDOT Wiki β

Changes

OPS435 Python Lab 3

190 bytes removed, 14:18, 30 May 2017
INVESTIGATION 1: USING FUNCTIONS
:In previous labs, you learned some programming tools in order to make your Python scripts '''more functional''' and allowed your Python script to run differently based on different data or situations. These tools included '''variables''', '''logic''' and '''loops'''. The utilization of these basic tools not only apply to Python scripts, but basically all programming languages including interpreted (including '''Perl scripts''', '''Bash Shell scripts''', '''JavaScript''', etc ) and compiled languages (including '''C''', '''C++''', '''Java''', etc).
:In this lab, you will learn the following tools including '''functions''', '''lists''', and '''loops''', with the primary focus on creating reusable code. These tools are used to make the program run more efficiently, and allow '''a program to be distributed among multiple individuals in a project team''' to help '''speed-up''' the completion of a program. 
:'''<u>Objectives</u>'''
= INVESTIGATION 1: USING FUNCTIONS =
:A very simple definition of a '''function ''' is like having '''smaller programs contained inside a larger program''' that can be run by name to perform '''repeated or commonly routine tasks'''. 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, the programming task can be viewed as creating coding blocks (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