Question: Write a program, in a file called FrequencyOfNumbers.py, which uses the following functions to perform the required tasks: a function called createList which generates N

Write a program, in a file called FrequencyOfNumbers.py, which uses the following functions to perform the required tasks:

  1. a function called createList which generates N random integers between 1 to 15 and stores them in a one-dimensional list. Note: The value of N is to be obtained as input from the user and passed as a parameter to the function. An empty list should also be passed as a parameter to store the resulting list.
  2. a function called findFreq which, given a list of random numbers, creates and returns a new list (of size 15) with the frequency counts of each number from 1 to 15 (i.e., a list containing the number of times each number from 1 to 15 occurs in the given list). Note/Hint: This function should use a single loop only (you should not need a nested loop for this).
  3. a function called findPowers which, given the frequency count list, returns a new list containing each number, from 1 to 15, raised to the power of its frequency. For example, if frequencyCount[11] holds a frequency value of 3, then position 11 of the new list would be assigned the result of 123 since index 11 holds the frequency of 12. (Hint: Use math.pow to compute the product of a number 123 = 1728)
  4. a main function to test all the functions and print the corresponding lists produced.

The input/output from the program would be similar to:

Please enter the number of integers in the list: 30 The list of 30 random numbers between 1 and 15 is: [5, 3, 15, 7, 1, 10, 10, 6, 5, 13, 10, 11, 11, 10, 10, 1, 8, 1, 14, 3, 13, 13, 5, 1, 3, 10, 1, 4, 3, 13] The frequency counts of the numbers from 1 to 15 are: [5, 0, 4, 1, 3, 1, 1, 1, 0, 6, 2, 0, 4, 1, 1] The numbers from 1 to 15 raised to the power of their frequency are: [1.0, 1.0, 81.0, 4.0, 125.0, 6.0, 7.0, 8.0, 1.0, 1000000.0, 121.0, 1.0, 28561.0, 14.0, 15.0]

Write a program, in a file called FrequencyOfNumbers.py, which uses the following

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!