Open main menu

CDOT Wiki β

Changes

OPS435 Python Lab 3

605 bytes added, 08:14, 2 June 2017
PART 1 - Using Functions
:::*Add a '''couple of empty lines''', following by a comment stating: '''# Main Program'''
:::*Add another '''couple of empty lines''', followed by the statements displayed below:<source>
if __name__ == '__main__': print('python code') text = return_text_value() print(text) number = return_number_value() print(str(number))</source>'''NOTE:''' The IF statement prior to the statements in the '''Main section''' of the '''lab3a.py''' script is considered to be a '''special IF statement'''. It allows scripts to be '''imported''' into other python scripts or shell environments so they can be used without having to add those functions into your current Python script. In order to use functions from other scripts, you are required to either issue the import command in your ipython3 shell environment, or use the import command within your Python script itself.<br><br>
:::2. Run your lab3a.py script in your ipython3 shell by issuing:
::::<source>
13,420
edits