For this lab, let’s use VSCode on Kali. (Not sure how to install it. Click Here)
Passing in command line arguments to a Python program is something you’ll commonly see and find helpful to include in your programs. Up to this point, we’ve been creating Python programs and running them like this:
python3 myprogram.py
Command line arguments are extra parameters that can be passed into a program at run time. It might look like this if we passed two command line arguments to the hypothetical program above.

In this lab, we’ll create a program that allows the end user to pass in values to a program. Create a folder called Lab08, and let’s call the program lab09.py. We’ll start by writing a program designed to analyze the parameters passed in by the end user.

Run the program like this, and you’ll see that it prints back the user-supplied arguments.

Just for demonstration purposes, modify/simplify the program so it now looks like this:

Now run it and consider the output:

Here’s the concept:
- The first value in the list (sys.argv[0]) will always be the program name
- The second value and beyond will contain whatever the user typed in, separated by spaces
Checkpoint/Challenge:
- Write a program that will loop through all user-supplied arguments (just like the first example).
- For the program to work, the user will have to supply integers.
- We won’t check for correct user input; we hope the user types in integers.
- Add each integer and print the sum
Example Output: