In this video, Kathryn introduces you to the system module, and shows how to use it to read a user's command line arguments. Learn how to access all the arguments in a given list, and take apart that list to get the arguments you really want.
- Using the system module, we are going to read in…a user's command-line arguments.…What are command-line arguments?…Well, they're the input that the user gives,…via the command line, before the program's execution.…In our example, the user will input numbers…in the command line, and we will output…the sum of these numbers.…Now, there're two ways we can do this.…The first is using the actual command line…that comes with your Mac or PC.…In the command line, all we have to do is write python…to the run the file, and then the file name,…which here is 03, there we go, and then we write…whatever command line arguments we want to add,…and so this is the input from the user,…and so I could go zero, one, two,…and those are my arguments.…
When I hit enter, nothing is going to happen,…because we haven't written anything on our program yet,…but this is how you would add command line arguments.…If you have an ide that you're using,…usually you can go into the configurations…and add the command line arguments that way.…So here, if we go to edit configurations,…
- Working with logical and comparison operators
- Getting a list of numbers with the range() and list() functions
- Using mathematical functions such as round(), abs(), and pow()
- Calculating a given input's length
- Importing and using the math module
- Reading a user's command-line arguments
- Getting the current time
- Formatting dates and times with datetime
- Creating a timer
- Using urllib to get content from the Internet
- Using the JSON module to decode content
Skill Level Intermediate
1. Python: What's Built-In?
2. Python: Math
3. Python: Input/Output
4. Python: Date & Time, HTML Parsing, and HTTP
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.