Changes

Jump to: navigation, search

OPS435 Python Lab 2

15 bytes added, 00:54, 25 May 2017
PART 1 - INPUT
'''lab2a'''
:#First lets start out with a very basic script. This script will use variables to print out specific information to the screen. Make the script '''lab2a.py''' with the following content. <presource>
#!/usr/bin/env python3
age = 20
print('Hi ' + name + ', you are ' + str(age) + ' years old.')
</presource:#Try running this script inside ipython3 and study the output:
<pre>
run lab2a.py
</pre>
:#This Python script is not very useful, it also gives the same output everytime it runs. In ipython3 lets use the input() function to get information from the user. Place a question or hint as a argument in the input() function, this will aid the user in typing in the correct information.
<pre>
</pre>
:#Now print out the variable '''colour''' and it should contain the value you entered after the prompt. 
<pre>
print(colour)
print('The colour I typed in is: ' + colour)
</pre>
:#If you didn't get the colour you typed in returned, try the above steps with the input() function again.
If you didn't get the colour you typed in returned, try the above steps with the input() function again. :#Download the check script and check your work. Enter the following commands from the bash shell.
<pre>
cd ~/ops435/lab2/
</pre>
:#Before proceeding, make certain that you identify any and all errors in "lab2a.py". When the check script tells you everything is "ok", you may procede to the next step.
198
edits

Navigation menu