Changes

Jump to: navigation, search

OPS435 Python Lab 3

290 bytes removed, 10:26, 10 August 2017
PART 1 - Providing Functions With Arguments
'''Importing Functions From other Python Scripts'''
In order to use functions from other scripts, you are required to either issue the import command in your ipython3 shell environment, or use the '''import ''' command within your Python script itself.<br><br>We can demonstrate the use of re-using functions from another script by simply '''issuing statements from the ipython shell by calling to call a function that is related to from your lab3a.py Python script'''. But care MUST be taken to first use the import command to load in the function declarations from your Python script to your ipython shell environment first.<br><br>
:'''Perform the following Instructions:'''
</source>
:# Before proceeding, make certain that you identify any and all errors in lab3a.py. When the checking script tells you everything is OK before proceeding to the next step.
 
::Make notes for all of your observations in your lab log book, and proceed to INVESTIGATION 2.
<br><br>
== PART 1 - Providing Functions With Arguments ==
:Functions can pass-up receive '''arguments''' - data to be used for processing. In this section, you will learn how to define functions that accept arguments and learn how to perform function calls that pass up call functions with arguments for processing (such as mathematical operations or testing conditions, which is useful for error-checking).
'''Passing up Single and Multiple Arguments to a Function'''
:#Start the ipython3 shell:<source>
ipython3
</source>When passing arguments up to functions, you MUST contain put data such as '''strings''', '''numbers''', or '''variable names''' within '''brackets''' immediately following the function name.<br><br>'''NOTE:''' If a function accepts arguments, then those '''arguments rguments must be defined''' declared (using variable names) when the function is declared.. Those declared variable names are then used within the function for processing. Also, when you call a function with arguments, the number of arguments passed up to the function must correspond (match) the number of arguments that were specified in the function declaration.<br><br>
:#Issue the following from the ipython shell to declare a function called '''square()''':<source>
def square(number):

Navigation menu