Changes

Jump to: navigation, search

OPS435 Python Lab 3

57 bytes removed, 12:49, 2 June 2017
PART 1 - Providing Functions With Arguments
</source>'''NOTE:''' Running functions with multiple arguments is the same. When you put a function as a argument of another function, the '''inner-most function will run first''', and the return the value '''10''' from the will be used as the argument for the '''outer function'''. In the example below, '''sum_numbers(5, 5)''' will return '''10''', thus providing that result to be square with that value '''square(10)'''.<br><br>
'''Practice Creating Functions a Function that Accept Accepts Arguments and Return ValuesReturns a Value'''
:It is time to practice creating a shell script that uses functions a function that accepts values as arguments that are then used by the functions for processing, and returns a value.
:'''Perform the Following Instructions:'''
:#Create a new script '''~/ops435/lab3/lab3b.py'''. Refer to the '''Python Script template''' and the '''Additional Requirements''' sections when creating your Python script. Refer to Sample Run and Sample Imports displayed below for exact prompt and output
:::'''Python Script Template'''
::::<source>#!/usr/bin/env python3
def sum_numbers(number1, number2):
</source>
:::'''Additional Requirements'''
:::*All functions should accept two arguments:::*All functions should return an integer:::*The script should contain no errors
:::'''Sample Run:'''<source>
run lab3b.py
15
50
</source>
:::'''Sample Run Using import:'''<source>
import lab3b
</source>
:::2. Exit the ipython3 shell, download the checking script and check your work. Enter the following commands from the bash shell.<source>
cd ~/ops435/lab3/
pwd #confirm that you are in the right directory
</source>
:::3. Before proceeding, make certain that you identify any and all errors in lab3b.py. When the checking script tells you everything is OK before proceeding to the next step.
'''Passing up Multiple Arguments and Using Logic Statements'''
13,420
edits

Navigation menu