example compare the following two programs from random import randint from random import randint rand_num randint( , for in range( )print'hello '*rand_numfor in range( )rand_num randint( , print'hello '*rand_numhello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello the only difference between the programs is in the placement of the rand_num statement in the first programit is located outside of the for loopand this means that rand_num is set once at the beginning of the program and retains that same value for the life of the program thus every print statement will print hello the same number of times in the second programthe rand_num statement is within the loop right before each print statementrand_num is assigned new random numberand so the number of times hello is printed will vary from line to line example let us write program that generates random numbers between and and counts how many of them are multiples of here are the things we will needbecause we are using random numbersthe first line of the program should import the random module we will require for loop to run times inside the loopwe will need to generate random numbercheck to see if it is divisible by and if soadd to the count since we are countingwe will also need to set the count equal to before we start counting to check divisibility by we use the modulo%operator when we put this all togetherwe get the followingfrom random import randint count for in range( )num randint( if num% == count=count+ print'number of multiples of 'count