Open main menu

CDOT Wiki β

Changes

OPS445 Online Lab3

316 bytes added, 15:45, 20 January 2023
wget addr switched to github
== PART 4 - Creating a Python Script with Functions and use them in another Python script==
<blockquote style="margin-left:35px;">{{Admon/note|style="padding-left:25px"|NOTE|If your professor is asking you to submit labs on GitHub, first follow their instructions on Blackboard to clone the lab3 repository.}}</blockquote>
'''Creating a Python Script'''
print(str(number))
</source>
:Running your program you should have seen three lines being displayed: the text "python code", a greeting, and a result of a math calculation. The '''if''' statement in the code above is a special '''if''' statement needed to make sure that your "main" code only runs when your script is executed by the Python interpreter directly, and will be ignored when you your python file is being imported by other script, or by an interactive python shell. More on that later.
'''Importing Functions From other Python Scripts'''
cd ~/ops445/lab3/
pwd #confirm that you are in the right directory
ls CheckLab3.py || wget 'https://ictgithub.senecacollege.cacom/~raymond.chansenecaops445/ops435lab3-template/labsblob/LabCheckScriptsmaster/CheckLab3.py?raw=true' -O CheckLab3.py
python3 ./CheckLab3.py -f -v lab3a
</source>
cd ~/ops445/lab3/
pwd #confirm that you are in the right directory
ls CheckLab3.py || wget 'https://ictgithub.senecacollege.cacom/~raymond.chansenecaops445/ops435lab3-template/labsblob/LabCheckScriptsmaster/CheckLab3.py?raw=true' -O CheckLab3.py
python3 ./CheckLab3.py -f -v lab3b
</source>
cd ~/ops445/lab3/
pwd #confirm that you are in the right directory
ls CheckLab3.py || wget 'https://ictgithub.senecacollege.cacom/~raymond.chansenecaops445/ops435lab3-template/labsblob/LabCheckScriptsmaster/CheckLab3.py?raw=true' -O CheckLab3.py
python3 ./CheckLab3.py -f -v lab3c
</source>
cd ~/ops445/lab3/
pwd #confirm that you are in the right directory
ls CheckLab3.py || wget 'https://ictgithub.senecacollege.cacom/~raymond.chansenecaops445/ops435lab3-template/labsblob/LabCheckScriptsmaster/CheckLab3.py?raw=true' -O CheckLab3.py
python3 ./CheckLab3.py -f -v lab3d
</source></li>
cd ~/ops445/lab3/
pwd #confirm that you are in the right directory
ls CheckLab3.py || wget 'https://ictgithub.senecacollege.cacom/~raymond.chansenecaops445/ops435lab3-template/labsblob/LabCheckScriptsmaster/CheckLab3.py?raw=true' -O CheckLab3.py
python3 ./CheckLab3.py -f -v lab3e
</source>
cd ~/ops445/lab3/
pwd #confirm that you are in the right directory
ls CheckLab3.py || wget 'https://ictgithub.senecacollege.cacom/~raymond.chansenecaops445/ops435lab3-template/labsblob/LabCheckScriptsmaster/CheckLab3.py?raw=true' -O CheckLab3.py
python3 ./CheckLab3.py -f -v lab3f
</source>