Changes

Jump to: navigation, search

OPS435 Python Lab 1

58 bytes added, 08:38, 16 May 2017
no edit summary
Next, we will make our first script with the above function. Open a new text file called "lab1a.py".
'''Perform the following steps:''' :# Edit the following file:<presource>
%vim ~/ops435/lab1/lab1a.py
</presource>  :#Write the following code into our python file. <presource>
#!/usr/bin/env python3
print('Hello world')
</presource:#Save the file and quit vim. We will now go over the process of manually running this python script. Both in the Bash shell and in the IPython shell.  :#Now lets try running the script directly from the IPython shell. by issuing the follwoing commands:<presource>
ipython3
%run ~/ops435/lab1/lab1a.py
</presource><br><br> Your python script should have run, if you have any errors you should check that you typed the script in exactly. Be careful of extra spaces, symbols, letters, or lowercase/uppercase differences. <br><br> :#Exit out of IPython. Now :3Now, from the Bash shell we will give it the correct linux permissions and run it. This is just showing the multiple ways you can use this python script. You are not required to have IPython running on a system, however hopefully we can use IPython's powerful features to our advantage. :# Issue the following command to exit your ipython session:<presource>
exit
</presource:# Run your python script by issuing the following commands:<presource>
chmod 755 ~/ops435/lab1/lab1a.py
python3 ~/ops435/lab1/lab1a.py
</presource>  This course is designed with a unit testing suite, which can be used to look at the scripts you write and give real-time feedback. This feedback is not perfect, however it may offer some hints if you get stuck with a error. It can also be used to make sure you are on the write track, and show progress. :#Download the check scriptand check your work. Enter the following commands from the bash shell.<presource>
cd ~/ops435/lab1/
pwd #confirm that you are in the right directory
ls CheckLab1.py || wget matrix.senecacollege.ca/~acoatley-willis/CheckLab1.py
python ./CheckLab1.py -f -v lab1a
</presource:#Before moving on to the next step make sure you identify any and all errors in "lab1a.py". When the check script tells you everything is "ok", you may proceed to the next step.:#Make notes for observations in your lab log book, and proceed to part 2.
=== PART 2 - Working with Variables ===
13,420
edits

Navigation menu