-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path33_set.py
More file actions
38 lines (31 loc) · 868 Bytes
/
Copy path33_set.py
File metadata and controls
38 lines (31 loc) · 868 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
"""A set in Python is used to store unique values (no duplicates).
Sets are:
Unordered
Mutable
Do not allow duplicate elements
Faster for searching and checking items"""
"""Unique student IDs in school databases
Unique phone numbers in contact lists
Unique visitors on a website
Unique email addresses in registration systems
Unique hashtags on social media platforms
Common subjects between students
Removing duplicate values from data
Fast searching in databases
Friend suggestion systems in social media
Inventory management systems
AI/Data cleaning applications"""
# sets are unordered ,unique collection(no duplicacy)
s={2,3,4,5,6}
print(s,type(s))
# print(s[2]) # you are not allow to access elemnt by index ,becoz sets are unordered.
# Set example
my_set = {11, 22, 33, 44}
# loop through set
for i in my_set:
print(i)
# Output:
# 11
# 22
# 33
# 44