From 3e23f3ecc7f6ff0a8a1b55df297673d0618e9137 Mon Sep 17 00:00:00 2001 From: Corey Schafer Date: Wed, 20 Jun 2018 10:22:07 -0600 Subject: [PATCH] Python Sets Snippets --- Python/Python-Sets/sets.py | 12 ++++++++++++ Python/Python-Sets/snippets.txt | 13 +++++++++++++ 2 files changed, 25 insertions(+) create mode 100644 Python/Python-Sets/sets.py create mode 100644 Python/Python-Sets/snippets.txt diff --git a/Python/Python-Sets/sets.py b/Python/Python-Sets/sets.py new file mode 100644 index 000000000..817aadb8c --- /dev/null +++ b/Python/Python-Sets/sets.py @@ -0,0 +1,12 @@ + +employees = ['Corey', 'Jim', 'Steven', 'April', 'Judy', 'Jenn', 'John', 'Jane'] + +gym_members = ['April', 'John', 'Corey'] + +developers = ['Judy', 'Corey', 'Steven', 'Jane', 'April'] + +if 'Corey' in developers: + print('Found!') + +# O(n) for list +# O(1) for a set diff --git a/Python/Python-Sets/snippets.txt b/Python/Python-Sets/snippets.txt new file mode 100644 index 000000000..259ab8f4b --- /dev/null +++ b/Python/Python-Sets/snippets.txt @@ -0,0 +1,13 @@ + +s1 = {1, 2, 3} +s2 = {2, 3, 4} +s3 = {3, 4, 5} + +# print(s4) + + +employees = ['Corey', 'Jim', 'Steven', 'April', 'Judy', 'Jenn', 'John', 'Jane'] + +gym_members = ['April', 'John', 'Corey'] + +developers = ['Judy', 'Corey', 'Steven', 'Jane', 'April']