Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adding some examples on set #18

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions Python/Sets/Introduction_to_Sets.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,27 @@
# When printed, iterated or converted into a sequence, its elements will appear in an arbitrary order.

# Basically, sets are used for membership testing and eliminating duplicate entries.
# let's get it through the example
# >> print set()
# set([])

# >>> print set('HackerRank')
# set(['a', 'c', 'e', 'H', 'k', 'n', 'r', 'R'])

# >>> print set([1,2,1,2,3,4,5,6,0,9,12,22,3])
# set([0, 1, 2, 3, 4, 5, 6, 9, 12, 22])

# >>> print set((1,2,3,4,5,5))
# set([1, 2, 3, 4, 5])

# >>> print set(set(['H','a','c','k','e','r','r','a','n','k']))
# set(['a', 'c', 'r', 'e', 'H', 'k', 'n'])

# >>> print set({'Hacker' : 'DOSHI', 'Rank' : 616 })
# set(['Hacker', 'Rank'])

# >>> print set(enumerate(['H','a','c','k','e','r','r','a','n','k']))
# set([(6, 'r'), (7, 'a'), (3, 'k'), (4, 'e'), (5, 'r'), (9, 'k'), (2, 'c'), (0, 'H'), (1, 'a'), (8, 'n')])

# Task
# Now, let's use our knowledge of sets and help Mickey.
Expand Down