Professional Documents
Culture Documents
Exercise Questions On Set 1
Exercise Questions On Set 1
1. Write a Python program to declare and initialize a set and perform following operations on them.
2. Declare and initialize two sets and perform following operations on them.
a. To create set difference.
b. To create a symmetric difference.
c. To print common elements between them
d. To obtain the values which are in set-A but not in set-B
e. To check whether they have any common element between them or not
3. Consider following set of Strings and print the String which has largest length among them.
{“Mahabaleshwar”, “Pune”, “Mumbai”, “Bangalore”, “Chennai”, “Vishakhapatnam”, “Kochi”}
4. Consider above set of String and prepare a list containing only length of each city names.
Expected output: [13, 4, 6, 9, 7, 14, 5]
5. Consider above set of Strings and prepare a dictionary containing {city_name : length} as key:value pairs.