1,760
edits
Changes
→PART 1 - Prompt the user for input data
:#Try running this script and study the output:<source>
./lab2a.py
: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 directoryls CheckLab2.py || wget https://ict.senecacollege.ca/~raymond.chan/ops435/labs/LabCheckScripts/CheckLab2.pypython3 ./CheckLab2.py -f -v lab2a</source>This :4. Before proceeding, make certain that you identify any and all errors in '''lab2b.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>:#Replace Copy lab2a.py to lab2a1.py and replace the print() call in your lab2alab2a1.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: ")
</source>