00:01
So in this question we are asked to generate a thousand random integers between 0 and 9.
00:09
And then we are asked to display the counts of each of those digits from 0 to 9.
00:14
How many counts there are in those thousand randomly generated numbers and display them? so here we'll be using a python library called random.
00:26
So we'll import random first because that helps us to generate the numbers.
00:31
And then we initialize a random list in which we'll put this thousand numbers called rand list.
00:39
It's an empty list initialization and then we take a four loop where we go from i, where we vary i from in a range of 0 to 1000 which means thousand different times the four loop will run.
00:55
So i in general does not it's not used here but this helps us to this helps us go through the operation a thousand times so in every operation what we're doing is we are creating a we are generating a random number n using random rand int 0 to 9 so in this case the rand int operation will take numbers which are between 0 and an inclusive of 0 and 9 and that's what we want and then what it does is in the next step it will append this to the rand list list and then this will happen thousand times such that the rand list in the end of this of four loop will have a thousand randomly picked integers.
01:40
So now we have the list.
01:41
Now the operation remaining is that we need to count it.
01:44
So what we can do in this case is that we can count the numbers by using the index of the numbers itself.
01:54
So what is happening is that our rand list is a number zero, i mean any random numbers between zero and nine.
02:08
So what we do is we initialize a array counts which is all zero in the beginning.
02:19
And there are there are 10 numbers here, 10 values which are all zero.
02:25
And each of these correspond to let's say zero, second one corresponds to one and the last one corresponds to nine.
02:31
And these are the digits we want to count, zero all the way to nine.
02:35
So what we'll do is if their number is zero, we will add one to this position...