Changes

Jump to: navigation, search

OPS435 Python3 Lab 2

1 byte removed, 15:25, 12 September 2019
PART 1 - Prompt the user for input data
:#Try running this script and study the output:<source>
./lab2a.py
</source>:3. #Download the checking script and check your work. Run the following commands from the bash shell.<source lang="bash">
cd ~/ops435/lab2/
pwd #confirm that you are in the right directory
python3 ./CheckLab2.py -f -v lab2a
</source>
:4. # Before proceeding, make certain that you identify any and all errors in '''lab2blab2a.py'''. When the check script tells you everything is '''OK''', you may procede to the next step.
</source>:#The above Python script '''lab2a.py''' is not very useful - the data are '''hard wired''' into the script: it displays the same output regardless of the number of times that this Python script is run.<br>The built-in '''input()''' function can be used to accept data in '''string form''' from the user and assign a name to the string object (used to be called a variable). It is typical to place a question (or hint) as an argument in the input() function: this will aid the user in typing in the correct data.<br><br>
:#Copy lab2a.py to lab2a1.py and replace the print() call in lab2a1.py with the following (you can just comment-out the print() call using a '''#''' at the beginning of the line): <source lang="python">
colour = input("Type in a colour and press enter: ")
1,760
edits

Navigation menu