Changes

Jump to: navigation, search

OPS435 Python Lab 2

80 bytes added, 03:06, 25 May 2017
INVESTIGATION 3: LOOPS
:::2. Download the check script and check your work. Enter the following commands from the bash shell.<presource>
cd ~/ops435/lab2/
pwd #confirm that you are in the right directory
ls CheckLab2.py || wget matrix.senecac.on.ca/~acoatley-willis/CheckLab2.py
python3 ./CheckLab2.py -f -v lab2f
</presource>
:::3. Before proceeding, make certain that you identify any and all errors in "lab2d.py". When the check script tells you everything is "ok", you may procede to the next step.
''' lab2g '''
:#Now lets make the same script EVEN more intelligent. Make a copy of '''lab2f.py''' and call it '''lab2g.py'''. Now modify '''lab2g.py''', add a if statement to the script that checks to see if a argument was entered. If a argument was entered use that number for the timer, if no argument was entered, timer should equal 3.
NOTEWARNING: When using arguments as number numbers/integers or performing math on arguments you must wrap them in the int() function: number = int(sys.argv[1])NOTEWARNING: Remember to check the number of arguments using len(sys.argv) in a if statement
::*The script should have a Shebang line::*The script should import sys::*The script should use a variable named timer with the value of 3 if no arguments are entered ::*The script should use a variable named timer with the value of int(sys.argv[1]) if arguments are entered ::*The script should have a while loop that repeats until timer equals 0::*The script should print the EXACT OUTPUT as shown
:::Sample run 1:<presource>
run lab2g.py 5
5
1
blast off!
</presource>
:::Sample run 2:<presource>
run lab2g.py 2
2
1
blast off!
</presource>
:::Sample run 3:<presource>
run lab2g.py
3
1
blast off!
</presource>  :::2. Download the check script and check your work. Enter the following commands from the bash shell.<presource>
cd ~/ops435/lab2/
pwd #confirm that you are in the right directory
ls CheckLab2.py || wget matrix.senecac.on.ca/~acoatley-willis/CheckLab2.py
python3 ./CheckLab2.py -f -v lab2g
</presource>
:::3. Before proceeding, make certain that you identify any and all errors in "lab2d.py". When the check script tells you everything is "ok", you may procede to the next step.
= LAB 2 SIGN-OFF (SHOW INSTRUCTOR) =
198
edits

Navigation menu