Question: PROBLEM 2 This program will demonstrate your ability to work with sets. Create a file named Lab 0 9 P 2 . py . Write
PROBLEM
This program will demonstrate your ability to work with sets.
Create a file named LabPpy Write a program that does the following:
a Generate random integers between and inclusive using the randint function from the random module. Store the random integers in a set named set Display the set. Please note that the set may have less than elements because some of the random integers generated may be duplicates.
b Create another set named set in the same way set was created.
c Find and display the union of set and set Make sure to include something in your output that indicates your output is for this step see sample output
d Find and display the intersection of set and set Make sure to include something in your output that indicates your output is for this step see sample output
e Find and display the difference of set and set Make sure to include something in your output that indicates your output is for this step see sample output
f Find and display the symmetric difference of set and set Make sure to include something in your output that indicates your output is for this step see sample output
g Use set comprehension to select the numbers less than from the union set in Step c and store them in a set. Display this set. Make sure to include something in your output that indicates your output is for this step see sample output
Sample output:
set:
set:
Union of set and set:
Intersection of set and set:
Difference of set and set:
Symmetric difference of set and set:
Less than in union of set and set:
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
