Learn how to get a list of numbers using the range() and list() functions. Given two numbers, the range function creates a range instance between those values that holds all the numbers between the first input and the second input. By putting this range instance into the list function, we can create a list that contains each value in the inputted range.
- [Voiceover] Let's learn how to use the range function.…The range function takes one whole number as input,…and so here it's "x", and it's going to output…a range instance that holds all the numbers…counting by one between zero and the only input.…Say "x" had the value "15",…then range(x) would output the value,…which is a range that holds all the numbers…counting by one between zero and 14,…because that's 15 numbers counting from zero…all the way to 14.…And there are other optional parameters…that we're going to learn about later.…
Basically you can set a starting point for the range…and you can also change how much it counts by…so it could count by one, by three, by five,…whatever you would like.…So here we'll create a variable called "numberedcontestants"…and it's going to have the value of range(30).…Range(30) will return a range instance…that includes all the numbers from zero to 29,…because zero to 29 would be 30 numbers.…Now to see that this range instance…is actually being created,…we have to learn about another function called "list."…
- 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.