198
edits
Changes
→PART 2 - Providing Functions With Arguments
20
</source>
:::4. 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
python3 ./CheckLab3.py -f -v lab3b
</source>
:::5. Before proceeding, make certain that you identify any and all errors in lab3b.py. When the check script tells you everything is ok before proceeding to the next step.
'''Multiple Arguments and IF Statements'''
Error: function operator can be "add", "subtract", or "multiply"
</source>
:::5. 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
python3 ./CheckLab3.py -f -v lab3c
</source>
:::6. Before proceeding, make certain that you identify any and all errors in lab3c.py. When the check script tells you everything is ok before proceeding to the next step.
== PART 3 - Running System Commands with Subprocess ==
'''Perform the Following Steps:'''
:#Start the ipython3 shell:<source>
import subprocess
dir(subprocess)
</source>
:#There are many available modules and attributes available as part of subprocess, we are interested in "'''Popen'''". This method subprocess.Popen() can be used to run system commands as a child process to the Python script. This below output will create a new child process, in Python we can control this through the new Python object we just created, "'''p'''". "'''p'''" now has a collection of methods(functions that are apart of a object) available, view them with '''dir()'''.<source>
p = subprocess.Popen(['date'], stdout=subprocess.PIPE, stdin=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)
dir(p)
</source>
:#This next step is going to communicate with the process and get the stdout and stderr from the command we previously.<source>
stdout, stderr = p.communicate()
stdout
stdout
</source>
:#While many of these system commands could be instead written in simply Python, the exercise of running system commands is important.
run lab3d.py
9.6G
</source>
:::3. Sample Import 1:<source>
import lab3d
'9.6G'
</source>
:::4. 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
python3 ./CheckLab3.py -f -v lab3d
</source>
:::5. Before proceeding, make certain that you identify any and all errors in lab3d.py. When the check script tells you everything is ok before proceeding to the next step.
= INVESTIGATION 2 - LISTS =