''' Purpose: Experience the thrill of random generation and list examination Task: Prompt and get three integers s, n, and d from its user (in that order). Use integer s as a seed to the Python random number generator. Then print n octal digits (base 8 digits) line by line by line. Then print the number of generated occurrences of d. There should be no other output Checker: ''' # needed module import random ##### Get the input reply = input( 'Enter three numbers: ' ) ##### Convert the input into the integers s, d, n s, n, d = reply.split() s, n, d = int( s ), int( n ), int( d ) ##### Set the seed for generating random values random.seed( s ) ##### Generate and print n random octal numbers and along the way store them in a list digit_list = [] # start off with an empty list # add n random 0, 1, 2, 3, 4, 5, 6, or 7's (i.e, octal digits) to numbers for i in range( 0, n ) : # i is the iterator, loop will repeat n times # each iteration want to add another digit to the list of digits next_digit = random.randrange( 0, 8 ) # get the next digit digit_list.append( next_digit ) # add the next digit to the end of the digit list # when all done print our list of octal digits print( digit_list ) # now we want to know the number of times digit d is in our list of digits occurrences = digit_list.count( d ) # counts the number of d's in the digit list print( occurrences )