Changes

Jump to: navigation, search

OPS435 Python3 Lab 2

1 byte added, 13:07, 12 September 2019
PART 1 - Prompt the user for input data
:#Try running this script and study the output:<source>
./lab2a.py
</source>This Python script is not very useful - the data are '''hard wired''' into the script: it displays the same output regardless of the number of times that the 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 a argument in the input() function: this will aid the user in typing in the correct data.<br><br>
:#Replace the print() call in your lab2a.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