Changes

Jump to: navigation, search

OPS435 Python Lab 1

104 bytes added, 19:43, 16 January 2018
Creating the introductory "Hello World" Script
:# Note that there are similarities between the Python print() function and the Bash echo command, but Python is more picky than bash (which is a good thing). Try to run print without the brackets or without the quotes to see what happens.
<blockquote style="margin-left:35px;">{{Admon/tip|Reading errors|One of the things that makes a good programmer is debugging skills. The first and most important debugging technique is reading and understanding error messages. Try to understand what the errors are saying even if you think you already know what the problem is and already have some idea about how to fix it.}}</blockquote>
<ol><li value="5" style="margin-left:#25px;">Write the following code into our python file. Note the she-bang line at the top of the file to run this script in the python3 environment. You will need to add this she-bang line for all python scripts you create for this course.<source lang="python">
#!/usr/bin/env python3
print('Hello world')
</source>
<li style="margin-left:#25px;">Another way of running a pythion program is executing it directly, e.g.: <source>./test.py</source>Note that the file will need execute permissions even though you ran it just fine earlier. Why is that?
:#Download the check script and check your work. Enter the following commands from the bash shell.<source lang="bash">
cd ~/ops435/lab1/
python3 ./CheckLab1.py -f -v lab1a
</source>
<li style="margin-left:#25px;">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.</ol>
=== PART 2 - Working with Variables ===

Navigation menu