Question: 4. The following function creates a random number from 1 to 1000 (inclusive): import random def getRandom(): val = int(random.random() * 1000) + 1
4. The following function creates a random number from 1 to 1000 (inclusive): import random def getRandom(): val = int(random.random() * 1000) + 1 return val a. Create a module with this single function (including the import statement) in a file called GetRandom.py b. Create a program that does the following: (10 marks) i. Generate two sets of 100 unique elements, each a random integer between 1 and 1000 inclusive. You must demonstrate the use of the getRandom() function by importing the module GetRandom into this program. ii. Display the number of elements that are the same in both sets. (You must use set operators or methods as part of your solution to this problem.) Do NOT display the elements themselves in your final solution - just the number that are the same. iii. Call this program RandomSetAnalysis.py
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
