Changes

Jump to: navigation, search

OPS435 Python Lab 1

12 bytes removed, 06:30, 18 May 2017
Creating the introductory "Hello World" Script
</source>You will notice that nothing happened when we ran this "print()" function. This is because we didn't pass any arguments to it, lets try again.<br><br>
:# Issue the following function:<br><source>
print('hello world')
</source>This time we should now see that the python function "print()" has outputted to the screen the words 'hello world'. In python a word or a bunch of characters like 'hello world' is called a 'string'. So what we did above is, passed a '''string''' as a '''argument''' to the print '''function'''. These words are important for understanding and talking about different aspects of code.
:# Using a text editor, open a new text file called '''lab1a.py''':<source>
vim ~/ops435/lab1/lab1a.py
</source>
:#Write the following code into our python file. <source>
:#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:<source>
run ~/ops435/lab1/lab1a.py</source><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>
:# Issue the following command to exit your ipython session:<source>
exit
</source>
:#Now, from the Bash shell we will give it the correct Linux permissions in order to run your newly-created python script. 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.
13,420
edits

Navigation menu