Introduction to Programming using Python 1st Edition

Published by Pearson
ISBN 10: 0132747189
ISBN 13: 978-0-13274-718-9

Chapter 14 - Tuples, Sets, and Dictionaries - Section 14.3 - Sets - Check Point - Programming Exercises - Page 483: 14.10

Answer

List stores the elements in a contiguous block of memory and set stores element via a hash map. In list insertion and deletion of element in the middle have O(N) complexity but in set elements can be inserted and removed in O(1) time. In list one element can be present multiple times but in set one element is present only once. In list the order of items is maintained but in set the items are in no particular order. To create set from list we pass the list as argument to set() function: Set=set(List) To create list from set we pass the set as argument to list() function: List=list(Set) To create tuple from set we pass the set as argument to tuple() function: Tuple = tuple(Set)

Work Step by Step

Same as above
Update this answer!

You can help us out by revising, improving and updating this answer.

Update this answer

After you claim an answer you’ll have 24 hours to send in a draft. An editor will review the submission and either publish your submission or provide feedback.