-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy path1.BasicOfSet.py
More file actions
39 lines (31 loc) · 933 Bytes
/
1.BasicOfSet.py
File metadata and controls
39 lines (31 loc) · 933 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
27
28
29
30
31
32
33
34
35
36
37
38
##------------------------------------------------------------------------------------------------------
#Created By:Ravishankar Chavare
#version:python 3.7
#Date:15/03/2019
#File_des:Introduction of Set Data Structure
##------------------------------------------------------------------------------------------------------
'''
Set
-A set is a collection which is unordered and unindexed.
-In Python sets are written with curly brackets.
simple syntax
myset={'value1','value2'}
or
myset=set() #for blank set
'''
#Create a Simple set with three elements
simpleset={'first','second','third'}
#TO get item from set
'''
Set doesnt contain index value becuase it is unordered list
we can use loop to get item from set or use 'in' to get elements
'''
#print the set
for i in simpleset:
print(i)
#Chek item in set
checkitem="first" in simpleset
print(checkitem)
#To get length of set
length=len(simpleset)
print(length)