From the course: Learning the Python 3 Standard Library
Unlock the full course today
Join today to access over 24,700 courses taught by industry experts.
Range and list - Python Tutorial
From the course: Learning the Python 3 Standard Library
Range and list
- [Instructor] 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 rangex 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 numbered contestants, 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…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
Logical operators: And, or, not6m 6s
-
(Locked)
Comparison operators4m 1s
-
(Locked)
Calculating length3m 45s
-
(Locked)
Range and list3m 18s
-
(Locked)
Min and max3m 54s
-
(Locked)
Rounding, absolute value, and exponents6m 8s
-
(Locked)
Sorted function6m 39s
-
(Locked)
Type functions5m 34s
-
(Locked)
Solution: Count valid numbers1m 13s
-
-
-
-
-