subject

Write a Python program for each of the problems in this lab. Please use PyCharm to type and test your programs. Problem 1
This program is about sets. Write a Python program to do the following:
(a) Generate 5 random integers between 1 and 10, inclusive. Store the random integers in a set named set1. Display the set. Please note that the set may have less than 5 elements because some of the random integers generated may be redundant.
(b) Generate 5 random integers between 1 and 10, inclusive. Store the random integers in another set named set2. Display the set. Please note that the set may have less than 5 elements because some of the random integers generated may be redundant.
(c) Find and display the union of set1 and set2.
(d) Use set comprehension to select odd numbers from the union and store them in a set. Display this set.
(e) Find and display the intersection of set1 and set2.
(f) Find and display the symmetric difference of set1 and set2.
The following is an example.
set1: {9, 10, 1, 7} set2: {8, 1, 7} Union of set1 and set2: {1, 7, 8, 9, 10} Odd numbers in union of seti and set2: {1, 9, 7}| Intersection of set1 and set2: {1, 7} Symmetric difference of set1 and set2: {8, 9, 10}

ansver
Answers: 1

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 11:30
Awell-diversified portfolio needs about 20-25 stocks from different categories is this true or false?
Answers: 2
question
Computers and Technology, 22.06.2019 20:00
What is the worst-case complexity of the maxrepeats function? assume that the longest string in the names array is at most 25 characters wide (i.e., string comparison can be treated as o( class namecounter { private: int* counts; int nc; string* names; int nn; public: namecounter (int ncounts, int nnames); int maxrepeats() const; }; int namecounter: : maxrepeats () { int maxcount = 0; for (int i = 0; i < nc; ++i) { int count = 1; for (int j = i+1; j < nc; ++j) { if (names[i] == names[j]) ++count; } maxcount = max(count, maxcount); } return maxcount; }
Answers: 3
question
Computers and Technology, 23.06.2019 15:30
Brian wants to conduct an online search with a certain phrase. he intends to use the words books that belong to the 1800s in his search. how should he use the word that in his search?
Answers: 1
question
Computers and Technology, 23.06.2019 17:00
The camera still is bad even with the new iphone xr and especially in low light it is even worst because you can see the pixels more if its in low light. if all you apple customers want apple to fix this then lets fill there feedback with complaints about the can apple do to fix this issue?
Answers: 1
You know the right answer?
Write a Python program for each of the problems in this lab. Please use PyCharm to type and test you...
Questions
question
Mathematics, 02.02.2020 15:56
question
Mathematics, 02.02.2020 15:56
Questions on the website: 13722360