13,420
edits
Changes
→Printing Text
:#Issue the following commands:<source>
ipython3% cd ~/ops435/lab1% pwd% ls
</source>Our first python code we will write is 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, issue the following python function:<source>
</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.