Quiz on Sets in Python
Q.1. Sets are immutable
Q.2. What is the possible output of followimg code?
s = {1,2,3,5,1}
print(s)
Q.3. Order is retained in sets
Q.4. What is the possible output of followimg code?
s = {'a','c','d','g'}
s.add('b')
print(s)
Q.5. What is the possible output of followimg code?
s = {5,4,7,8,3,9}
s.sort()
print(s)
Q.6. What will happen if an element is added to the below set:
s = {1,2,3,4]
s.add(4)
Q.7. What is the possible output of followimg code?
s1 = {10, 20, 30, 40}
s2 = {50, 60, 70, 80}
s3 = s1.union(s2)
print(s3)
Q.8. What is the possible output of followimg code?
s = {'apple', 'orange', 'mango'}
print(s[1])
Q.9. Duplicates are allowed in sets
Q.10. Which statement of the following is false regarding sets in Python?
Q.11. Initializing a set as " s = {"abc", 34, True, 40, "male"} " would give an error
Q.12. What is the possible output of the follwing code?
s1 = {'apple', 'orange', 'mango'}
s2 = {'apple', 'orange', 'banana'}
s3 = s1.union(s2)
print(s3)
Q.13. What is the possible output of the follwing code?
s1 = {"Yellow", "Orange", "Black"}
s2 = {"Orange", "Blue", "Pink"}
s3 = s2.difference(s1)
print(s3)
Q.14. The symmetric_difference() method returns a set that contains all items from both sets, but not
the items that are present in both sets.
Q.15. What is the possible output of the follwing code?
s1 = {10, 20, 30, 40}
s2 = {50, 60, 70, 80}
s3 = s1.intersection(s2)
print(s3)
Instructions:-
- This Quiz is based on Dictionary in Python
- Each correct answer will carry 2 points
- Once an option is selected you cannot select any other, So choose wisely
- Do not refresh the page as it will reset the quiz
- Once the time is up the quiz will automatically get submitted with no of Question responded
- Your total score alongwith your name will be shown after submission of the Quiz
- Wish you ALL THE BEST 👍👍
START
Post a Comment
FOR ANY DOUBTS AND ERRORS FEEL FREE TO ASK. YOUR DOUBTS WILL BE ADDRESSED ASAP