Changes

Jump to: navigation, search

OPS435 Python Lab 1

373 bytes added, 20:31, 16 January 2018
Printing Text
====Printing Text====
:Let's start IPython interpreter Python code editor and start writing some python code.
:'''Perform the following steps:'''
:#Issue the following commands:<source> ipython3 cd Create a new python file in your ~/ops435/lab1 pwd ls</source>Our directory. Call it test.py or whatever makes sense for you - this will be a temporary file for trying simple Python programming language features. The first python Python code we will write is going to call the print function. A function is code that has been defined in another location. Functions can take arguments, use these arguments in some way, and then usually return a result. The first function we will use is the "print()" functions, it's sole purpose is to output information to the screen.<br><br>:#At the prompt, execute Add the followingline into your source code file:<source>
print()
</source>And run it from the command-line in one of two ways:<source>./test.py</source> or <source>python3 ./test.py</source>Note that the file will need execute permissions for the first way of running it, but not for the second. Why is that? You will also notice that nothing happened when is printed even though we ran this called the "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')

Navigation menu