Skip to playerSkip to main contentSkip to footer
  • 5/20/2025
The range() function in Python generates a sequence of numbers. It is commonly used in loops to iterate a specific number of times. The function can take one, two, or three arguments:
range(stop):
Generates numbers from 0 up to (but not including) stop, incrementing by 1.
range(start, stop):
Generates numbers from start up to (but not including) stop, incrementing by 1.

Category

📚
Learning
Transcript
00:00Now we will talk about range function, but I will explain the range function, and then I will show you the utilization of it.
00:09Now, in the last lecture, I had a point that I had said that I had a list of 100 of the list.
00:17So, 100 of the list will generate 100 of the list.
00:22So, this is 10, 11, 12, 13, so I have a list of 100 to be efficient way to generate.
00:32So, this is a built-in function.
00:34Range is a range.
00:36Range is a range.
00:38Range is a range function, and I remove this function.
00:42And then I will remove this function.
00:45So, we will do this function.
00:48Range is a function.
00:50Your function is a function function too.
00:53wide!
00:55Can you choose some effect again?
00:56Notice that there needs to be constant.
00:57The 정도 function of speed function goes...
00:59If you want to� govern maintenance function, do you have 6 of the page function or do you need to choose?
01:05If I understand the benefits function is a change function, I will стres the functionだ.
01:07So, over the slide, I will send you 2 of these functions.
01:11So, change the values function, 4 of theuli functions functions.
01:13The number of these functions function is 5 elements.
01:15If I run as matches function, if I run without addinguche functions then you cannot exclude.
01:17If you have step size, then automatically step size is 1.
01:21If you have step size 2, then it will be 0, 2, 4, 6.
01:25If you have step size 3, then it will be 0, 3, 6 and 9 and so on.
01:30Okay, so this is step size.
01:31So, first of all, simple range to generate.
01:34Now, if you have to print this range,
01:37you will see that you will see that we will get a range iterator,
01:41but it will not get a range.
01:43And range is 0 to 10.
01:46So, you can ask me,
01:48Sir, you promised me that you will get a list from 1 to 10.
01:51But the list will not come.
01:52However, interesting enough,
01:54that we will get an iterator.
01:56We can use this straight away.
01:58We can convert this to the list.
02:02Using the list function.
02:04Now, I will execute this list.
02:08And it gives me an error.
02:10The reason is that I have parenthesis here.
02:14And you see list.
02:160 to 9.
02:17However,
02:18we can use this for loop.
02:20We can use this for loop.
02:21For x in range.
02:23And range is 0 to 10.
02:27Print x.
02:29Execute.
02:30And you will see.
02:320 to 9.
02:33So, you will find the list.
02:34And you will find the list.
02:35And you will find the proper operation.
02:36Okay?
02:37Now, you will find it.
02:38Range.
02:39Basically.
02:40If I simply write this as a range.
02:4410.
02:45Then I will write exactly this.
02:48Range.
02:490 to 10.
02:51Okay?
02:52Okay?
02:53So, if you have a default start value.
02:55If you have a default start value.
02:56Then the defaults count.
02:57So, in this case.
02:58For example.
02:59I will say range 10.
03:00Generate.
03:01Okay.
03:02Range.
03:03Range.
03:04If you want to generate even number.
03:07Or list.
03:08Or odd number.
03:09You can easily do that.
03:11With no problem.
03:12I will say 0 to 10.
03:14But on every two steps.
03:17Step.
03:18So, this is which.
03:19Sorry.
03:20I will convert it in the list.
03:21And then I will print it.
03:24Just like that.
03:25P-R-I-N-T.
03:26Execute.
03:27So, this will give us a list.
03:30Which numbers?
03:310, 2, 4, 6.
03:32Even numbers.
03:33Just like that.
03:36What if.
03:37If I need odd number.
03:38So, I will start with step size 2.
03:41Step size 2.
03:422, 3.
03:43And so on.
03:442, 3.
03:45And so on.
03:46The list.
03:47Now interesting enough.
03:48I will just add 0 to odd.
03:51And you will have an odd number list.
03:52Until 100.
03:53Isn't it cool?
03:54It's very cool.
03:55And if I have 0.
03:56So, if I have a list.
03:57You have to have a list.
03:58You have to have a list.
03:59This is very cool.
04:00And very powerful.
04:01This is very cool.
04:02And very powerful.
04:03Now we will do this.
04:05We will do this.
04:06On the previous code.
04:07And this range.
04:08And this range.
04:09I will use.
04:10Okay.
04:11We will do this.
04:12We will do this.
04:13We will do this.
04:14We will do this.
04:15And then.
04:16And then.
04:17Range 10.
04:18That's it.
04:19Now we will do this.
04:20We will do this.
04:21And then.
04:22And then.
04:23Range 10.
04:24That's it.
04:25Now we will do this.
04:26We will do this.
04:27We will do this.
04:28Now we will do this.
04:29We will do this.
04:30We will do this.
04:31Now we will do this.
04:32Now we will do this.
04:33And we will do this.
04:34and you see the same result, this is cool, right?
04:38However, a small thing,
04:40basically, if you are 10,
04:42you will print 10 elements, starting from 0,
04:45okay, starting from 0,
04:4810 elements to print,
04:49this total is 9,
04:50so this is why this is 9,
04:51then you have to include,
04:52make sure,
04:53that you have to go up to a number.
04:55This is the number of elements,
04:57okay,
04:58now you will see,
04:59that you will have full range,
05:02now you will see,
05:04100 to generate,
05:07how clean code is,
05:09and you have got everything you want,
05:11as you see,
05:12right?
05:13It is very cool,
05:14okay,
05:15so this is all table,
05:16within snap of a finger,
05:17generate,
05:18now range is a hidden function,
05:21which basically,
05:22I don't know how many people know,
05:24I will tell you.
05:25If you give range,
05:260 is start point,
05:28and 10 is end point,
05:29and not anything else,
05:31when I write,
05:34basically list,
05:35I will tell you,
05:37basically list generate,
05:38this list generate,
05:39you are going to tell me,
05:40it will be,
05:41okay,
05:42alright,
05:43I will tell you,
05:44this list can name,
05:45I will tell you,
05:46comment out,
05:47comment out,
05:49execute,
05:50and then,
05:51to 10 is end point,
05:52I will tell you,
05:53right,
05:54what if,
05:55I will say this list,
05:56reverse
05:56کرنا
05:57چاہتا
05:57ہوں
05:57یعنی
05:58inverse
05:58کرنا
05:58چاہتا
05:59ہوں
05:59پہلے
05:59میں
05:59کہتا
05:59ہوں
05:599
06:00آئے
06:00پھر
06:01بعد
06:01میں
06:018
06:02آئے
06:02and
06:02so
06:03on
06:03یہ
06:04کیسے
06:04ہوگا
06:05ایک
06:06تو
06:06کام
06:06یہ
06:06ہے
06:06کہ
06:06یہ
06:07پہ
06:07کہہ
06:07سکتا
06:07ہوں
06:0710
06:08سے
06:09شروع
06:09کرو
06:09اور
06:100
06:10پہ
06:10لے
06:10جاؤ
06:10اب
06:11میں
06:11run
06:11کرتا
06:12ہوں
06:12we
06:13see
06:13nothing
06:14what
06:14is
06:14the
06:14problem
06:15what
06:16is
06:16the
06:16problem
06:17وہ
06:17کہہ
06:17رہی
06:170
06:18point
06:18ہے
06:18starting
06:20point
06:2010
06:21ہے
06:21اس نے
06:21کہا
06:22ٹھیک ہے
06:2210
06:22لے لیا
06:22میں
06:23نے
06:23اب
06:23آگے
06:23کدھر
06:24جانا
06:24ہے
06:24میں
06:24نے
06:24اس نے
06:25کہا
06:25آگے
06:250
06:26don't
06:27understand
06:27basically
06:29کہ
06:30اس نے
06:31کس
06:32طریقے
06:32سے
06:32step
06:33size
06:33لینا
06:33ہے
06:33by
06:34default
06:34step
06:35size
06:351
06:35ہوتا
06:36ہے
06:36تو
06:37by
06:37default
06:37جب
06:37اس
06:37نے
06:371
06:38step
06:38size
06:38رکھا
06:39تو
06:39اس نے
06:39کہا
06:39end
06:40point
06:40پہ
06:40تو
06:40میں
06:41نہیں
06:41meet
06:41کر
06:41سکتا
06:41کیونکہ
06:4210
06:42plus
06:431
06:43کر
06:43دوں
06:4311
06:43چلا
06:44جاتا
06:440
06:44تو
06:44کبھی
06:44بھی
06:45نہیں
06:45آئے
06:45گا
06:45تو
06:46اس لئے
06:46وہ
06:46روک گیا
06:46however
06:47اگر
06:47step
06:47size
06:48minus
06:481
06:48رکھتا
06:49ہوں
06:49تو
06:49اب
06:49اس
06:49کو
06:49پتا
06:50ہے
06:50کہ
06:5010
06:509
06:518
06:51and
06:52so
06:52on
06:52کر
06:52کے
06:520
06:53پہ
06:53پہ
06:53پہ
06:53پہ
06:53پہ
06:54پہ
06:54پہ
06:54پہ
06:55پہ
06:55پہ
06:56پہ
06:56پہ
06:56پہ
06:57پہ
07:02پہ
07:03پہ
07:03پہ
07:03اس
07:04کو
07:05کامنٹ
07:07آؤٹ
07:07کرتا
07:07ہوں
07:07اور
07:08آپ
07:08ان
07:10ورس
07:10میں
07:10جنریٹ
07:10کرانا
07:11چاہتے
07:11ہیں
07:11یہ
07:12table
07:12تو
07:12آپ
07:12کہیں
07:120
07:13کاما
07:13minus
07:141
07:14ٹھیک
07:15ہے
07:150
07:16کاما
07:17minus
07:181
07:18تو
07:19اب
07:19آپ
07:19کا
07:2099
07:20والا
07:21table
07:21پہلے
07:21جنریٹ
07:21ہوگا
07:22and
07:22it
07:22will
07:22keep
07:23on
07:23going
07:23down
07:23اب
07:24دیکھئے
07:24and
07:251
07:25is
07:26at
07:26the
07:27end
07:27اور
07:27top
07:28پہ
07:28جو ہے
07:28آپ
07:28کا
07:29کون
07:29سا
07:29ہے
07:29top
07:30پہ
07:30آپ
07:30کا
07:3199
07:33والا
07:33ٹھیک
07:34ہے
07:35یہ
07:35دیکھئے
07:3599
07:36والا
07:36top
07:36ہے
07:36وہ
07:3699
07:38والا
07:39ٹھیک
07:40ہے
07:40یہ
07:40دیکھئے
07:4099
07:41والا
07:41top
07:41ہے
07:41excellent
07:42اوکی
07:43گائز
07:44تو
07:44یہاں
07:44پہ
07:44اس
07:45range
07:45کو
07:45کرتے
07:45close
07:46it's
07:46very
07:46powerful
07:47very
07:47helpful
07:47tool
07:48اور
07:49آپ
07:49دیکھیں
07:49گے
07:49کہ
07:49machine
07:49learning
07:50application
07:50میں
07:50اس
07:51کو
07:51بہت
07:51زیادہ
07:51ہی

Recommended