2. Print the set. Did it keep the order of the elements ?
3. Find the maximum and the minimum of the set.
4. Add the element of this list [False, 3.14, ‘Rose’] to the set.
5. Print the set. What is the order of the elements ?
6. Try to add another 1 to the set. Is it working ? Why ?
Right Answer:
# Step 1
num_set = {5, 1, 3, 7, 8, 2, 3}
# Step 2
print(num_set) # Order is not preserved in sets
# Step 3
print("Max:", max(num_set)) # Max: 8
print("Min:", min(num_set)) # Min: 1
# Step 4
num_set.update([False, 3.14, "Rose"])
# Step 5
print(num_set) # Order is arbitrary in sets
# Step 6
num_set.add(1) # Adding a duplicate doesn't change the set