What is the sys module (will also accept sys.argv).
The importing of the argparse module occurs on this line.
What is line 3
What is the syntax required to define an argument using the argparse module?
parser.add_argument()
What does a flag do?
Assigns an identity to an argument, allows users to choose what order they enter arguments
A module that allows your script to run shell commands from within the script via a temporary bash shell.
What is the subprocess module
What is happening on line 22?
The parser is being created which allows the script to have arguments defined. The description in the inside is optional but shown when --help flag is used.
The keyword argument that determines whether a user must enter something or not on the command line interface?
What is Required=true/false
What might be the short option flag for --name?
-n
**DAILY DOUBLE**
A module that provides low-level networking interfaces.
What is the socket module.
What is happening on lines 48-54?
An argument is being created with the long option flag --credits, type assigned as float, default set to 15.0, adding help information, and assigning the argument a user-friendly name of CREDITS.
The keyword argument that assigns a value to an argument if the user does not?
What is default=
Can an argument have more than one of each type of flag?
Yes
A module that allows you to collect input via flagged arguments on the command line.
What is the benefit of line 51 and why don't we see that same parameter defined in the argument for --new-grade?
A default value is being set in case the user doesn't enter their amount of credits. This isn't in the --new-grade argument because that would defeat the purpose of the script's function.
The only data type that we do not have to explicitly define.
What is type=str
-or-
string
Why would we use the long vs short options of flags?
Usability
What is
if __name__="__main__":
It is an argument defined on lines 56-60. Verbose is a common term used in programming to flag the argument that controls how much output information is displayed.
What is missing in the line of code below?
def calculate_new_gpa(previous_gpa new_grade credits name verbose)
Commas and the colon (, & :)
Are flags required in arguments?
No, but excluding flags takes away some of the magic of the argparse module. Without flags, users must enter arguments in the exact order they are coded in our script.