1 00:00:00,210 --> 00:00:10,020 In this tutorial we will talk about the built in function in Python range the range function generate 2 00:00:10,140 --> 00:00:21,840 integer numbers between the given start integer and stop integer and using a for loop begin I iterate 3 00:00:21,930 --> 00:00:22,380 or what. 4 00:00:22,380 --> 00:00:31,120 These generated integers and this is the syntax for D range function out of the three arguments start 5 00:00:31,140 --> 00:00:40,950 stop and step dad and step add optional argument and they start argument is a starting number of the 6 00:00:40,950 --> 00:00:45,210 sequence that does the lower element by default. 7 00:00:45,210 --> 00:00:47,040 It starts with 0. 8 00:00:47,100 --> 00:00:56,430 If it does not specify this top argument this top argument is the upper limit that is generate numbers 9 00:00:56,520 --> 00:00:57,690 up to this number. 10 00:00:58,820 --> 00:01:03,260 Then the range function does not include this number in the result. 11 00:01:04,290 --> 00:01:13,220 The step argument is a difference between each number in the result and the default value of step is 12 00:01:13,220 --> 00:01:13,580 1. 13 00:01:13,610 --> 00:01:21,170 If it does not specify so using a for loop we are going to iterate over the numbers generated using 14 00:01:21,170 --> 00:01:23,240 this range function. 15 00:01:23,240 --> 00:01:27,500 The lower limit that that is the start argument is 1. 16 00:01:27,530 --> 00:01:33,890 So the sequence starts with this number and the upper limit. 17 00:01:33,910 --> 00:01:34,760 These top. 18 00:01:34,790 --> 00:01:47,050 Argument is 10 and the resultant output does not include the stop argument and the step argument is 19 00:01:47,460 --> 00:01:48,150 2. 20 00:01:48,280 --> 00:01:54,460 That means the difference between between each number in the output should be 2. 21 00:01:54,490 --> 00:02:01,720 Now we are going to use a for loop to iterate or what the numbers generated using the range function 22 00:02:02,160 --> 00:02:04,920 and let and then print the number. 23 00:02:05,140 --> 00:02:07,670 So let's execute this piece of code. 24 00:02:07,900 --> 00:02:17,500 As you can see the numbers have been generated from the starting argument up until number 9 integer 25 00:02:17,600 --> 00:02:20,870 9 excluding these top arguments. 26 00:02:20,920 --> 00:02:28,510 For example you want to print the sequence of numbers in the reverse order using the range function 27 00:02:29,140 --> 00:02:34,420 or you want to print the sequence of numbers in the descending order. 28 00:02:34,420 --> 00:02:43,420 In that case in that case say for example your starting argument you start argument is 10 and you want 29 00:02:43,420 --> 00:02:47,140 to print numbers up until 2. 30 00:02:47,410 --> 00:02:55,170 So the stop argument should be 1 and because you want to print the numbers in that it was ordered. 31 00:02:55,490 --> 00:03:04,200 Thus difference between each number and the result should be minus 1 in the descending order. 32 00:03:04,330 --> 00:03:07,880 So let's execute this piece of code. 33 00:03:07,930 --> 00:03:12,290 So here you have the numbers printed in that he was ordered. 34 00:03:12,620 --> 00:03:21,390 The python range function returns an immutable sequence object of integer so it is possible to convert 35 00:03:21,400 --> 00:03:26,350 the output of the change function to a Python list. 36 00:03:26,350 --> 00:03:31,960 So in order to do this we have to parse the range object to the list function. 37 00:03:32,050 --> 00:03:34,150 So let's see how this can be done. 38 00:03:35,310 --> 00:03:44,720 Let's say we are going to create list 1 and we need to parse the range object to the list function. 39 00:03:44,830 --> 00:03:48,820 Convert the output of the range function to a Python list. 40 00:03:48,850 --> 00:03:59,150 So in order to do that let's call the range function and say we're going to pass the stop and the start 41 00:03:59,150 --> 00:04:04,950 and this top argument is 1 and 10 and then execute. 42 00:04:05,270 --> 00:04:11,930 And when you display the list 1 The Range object has been converted to a list.