Python Sets Quiz Read Courses Jobs Python Sets Quiz Please wait while the activity loads. If this activity does not load, try refreshing your browser. Also, this page requires javascript. Please visit using a browser with javascript enabled. If loading fails, click here to try again Question 1Question 1: What is the output of the following program? sets = {1, 2, 3, 4, 4} print(sets) {1, 2, 3}{1, 2, 3, 4}{1, 2, 3, 4, 4}ErrorPython Sets Quiz Discuss itQuestion 1-Explanation: Duplicate values are not allowed in sets. Hence, the output of the code shown above will be a set containing the duplicate value only once. Hence output will be {1, 2, 3, 4}.Question 2Question 2: What is the output of the following program? sets = {3, 4, 5} sets.update([1, 2, 3]) print(sets) {1, 2, 3, 4, 5}{3, 4, 5, 1, 2, 3}{1, 2, 3, 3, 4, 5}ErrorPython Sets Quiz Discuss itQuestion 2-Explanation: The method update adds elements to a set.Question 3Question 3: What is the output of the following program? set1 = {1, 2, 3} set2 = set1.copy() set2.add(4) print(set1) {1, 2, 3, 4}{1, 2, 3}Invalid SyntaxErrorPython Sets Quiz Discuss itQuestion 3-Explanation: In the above piece of code, set2 is barely a copy and not an alias of set1. Hence any change made in set2 isn’t reflected in set1.Question 4Question 4: What is the output of the following program? set1 = {1, 2, 3} set2 = set1.add(4) print(set2) {1, 2, 3, 4}{1, 2, 3}Invalid SyntaxNonePython Sets Quiz Discuss itQuestion 4-Explanation: The add method doesn’t return anything. Hence there will be no output.Question 5Question 5: What is the output of the following program? set1 = {1, 2, 3} set2 = {4, 5, 6} print(len(set1 + set2)) 36UnexpectedErrorPython Sets Quiz Discuss itQuestion 5-Explanation: The unsupported operand type(s) for +: ‘set’ and ‘set’.Question 6Question 6: What is the output of the following program? A = {0, 2, 4, 6, 8}; B = {1, 2, 3, 4, 5}; print(A | B) {0, 1, 2, 3, 4, 5}{0, 1, 2, 3, 4, 5, 6, 8}{ 6, 8}NonePython Sets Quiz Discuss itQuestion 6-Explanation: The "|" operator is used for union.Question 7Question 7: What is the output of the following program? A = {0, 2, 4, 6, 8}; B = {1, 2, 3, 4, 5}; print(A & B) {0, 1, 2, 3, 4, 5, 6, 8}{0, 1, 3, 5, 6, 8}{2, 4}{0, 8, 6}Python Sets Quiz Discuss itQuestion 7-Explanation: The "&" operator is used for intersection.Question 8Question 8: What is the output of the following program? A = {0, 2, 4, 6, 8}; B = {1, 2, 3, 4, 5}; print( A - B) {0, 1, 2, 3, 4, 5, 6, 8}{0, 8, 6}{2, 4}{0, 1, 3, 5, 6, 8}Python Sets Quiz Discuss itQuestion 8-Explanation: The "-" operator is used to get the difference between two iterable.Question 9Question 9: What is the output of the following program? A = {0, 2, 4, 6, 8}; B = {1, 2, 3, 4, 5}; print( A ^ B) {0, 1, 2, 3, 4, 5, 6, 8}{2, 4}{0, 8, 6}{0, 1, 3, 5, 6, 8}Python Sets Quiz Discuss itQuestion 9-Explanation: The "^" operator is used to get the Symmetric difference.Question 10Question 10: What is the output of the following program? set1 = set([1, 2, 4, 4, 3, 3, 3, 6, 5]) print(set1) {1, 2, 4, 4, 3, 3, 3, 6, 5}{1, 2, 3, 4, 5, 6}[1, 2, 3, 4, 5, 6][1, 2, 4, 4, 3, 3, 3, 6, 5]Python Sets Quiz Discuss itQuestion 10-Explanation: All the elements in sets must be unique. 12 There are 11 questions to complete. You have completed questions question Your accuracy is Correct Wrong Partial-Credit You have not finished your quiz. If you leave this page, your progress will be lost. Correct Answer You Selected Not Attempted Final Score on Quiz Attempted Questions Correct Attempted Questions Wrong Questions Not Attempted Total Questions on Quiz Question Details Results Date Score Hint Time allowed minutes seconds Time used Answer Choice(s) Selected Question Text All doneNeed more practice!Keep trying!Not bad!Good work!Perfect! Commit to GfG's Three-90 Challenge! Purchase a course, complete 90% in 90 days, and save 90% cost click here to explore. Last Updated : 18 Sep, 2020 Share your thoughts in the comments Add Your Comment Please Login to comment...