-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathset.py
More file actions
26 lines (21 loc) · 812 Bytes
/
set.py
File metadata and controls
26 lines (21 loc) · 812 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#SET OPERATIONS
x=set("Welcome to Python World")
print("\n=================Set allows only unique values=================\n")
print("\nDisplaying Set -->> ",x)
#DEFINE SET DATA TYPE
l = ['s','s','d']
#CONVERT LIST TO SET
g = set(l)
'''
PRINT A SET ( IT REMOVES A DUPLICATE CHARACTERS FROM A LIST
SET IS AN UNORDERED COLLECTION WHICH HAS UNIQUE ELEMENT IN IT
'''
#PRINT SET
print("\n Displaying set after converting from list -->> ",g)
#PRINT LENGTH
print("Set length -->> ",len(g))
employees=["ram","kiran","raj","prem", "ram","kiran"]
print("\nPrinting Employees -->> ",employees,", Employees Length : ",len(employees))
print("\nConverting from list to set\n")
employeeSet = set(employees)
print("Displaying Set values after converting from list -->> ",employeeSet,", Employees Length : ",len(employeeSet))