13,420
edits
Changes
→PART 1 - Using IF Statements
<blockquote style="margin-left:35px;">{{Admon/important|style="padding-left:25px"|Number of Arguments with len(sys.argv)|If you are running the '''len(sys.argv)''' function in ipython3, the number of arguments returned will be always be '1'. This number will always be one higher than the actual number of arguments entered, since it also counts the script name as a argument.}}</blockquote>
''' Practice Using IF Statements '''
:#Now it's time to create a new script. Make a copy of '''lab2c.py''' and call it '''lab2d.py'''. Now modify '''lab2d.py''', add a if statement right before your print statements. This if statement should make sure that lab2d.py is using '2' additional arguments.
''' Practice Using IF Statements''':Now it's time to create a new script. You will be modifying the previous Python script to provide a message if the user did NOT provide any argument when running the script, and abort the script if two additional arguments are not provided. Refer to Sample Runs displayed below for exact prompt and output requirements. :'''Perform the following Instructions:''' ::*The script should have a '''Shebang line'''
::*The script should import sys
::*The script should print a usage message IF additional arguments are not given