Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

Comparing Sets with issubset() Function in python

# The issubset() function can be used to determine if a set is a subset of another
# set. Let’s see an example:

mySet = {2, 4}
mySet2 = {1, 2, 3, 4, 5}
print(mySet.issubset(mySet2))

# Output:
# True

# Looking at the example above, we can tell by the output that mySet is a subset
# of mySet2, meaning that all the values in mySet is also within mySet2.
# Let’s see what happens if we check to see if mySet2 is a subset of mySet:

mySet = {2, 4}
mySet2 = {1, 2, 3, 4, 5}
print(mySet2.issubset(mySet))

# Output:
# False

# Looking at the example above, we can verify that mySet2 is not a subset of mySet
# as not all of it’s values are in mySet.
Comment

Comparing Sets with issubset() Function in python

# The issuperset() function can be used to determine if a set is a superset of
# another set. Let’s see an example:

mySet = {2, 4}
mySet2 = {1, 2, 3, 4, 5}
print(mySet.issuperset(mySet2))

# Output:
# False

# Looking at the example above, we can tell by the output that mySet is not a
# superset of mySet2, meaning that mySet does not contain all the values that are
# within mySet2. Let’s see what happens if we check if mySet2 is a superset of mySet:

mySet = {2, 4}
mySet2 = {1, 2, 3, 4, 5}
print(mySet2.issuperset(mySet))

# Output:
# True

# Looking at the example above, we can verify that mySet2 is a superset of mySet.
Comment

PREVIOUS NEXT
Code Example
Python :: How to clear out a set in python 
Python :: design patterns python - restrict what methods of the wrapped class to expose 
Python :: Shallow copy in python and adding another array to list 
Python :: python math.factorial algorithm 
Python :: csrf is not detected using sendbeacon django 
Python :: save PIL image to s3 
Python :: Location of INSTALLED_APP and MIDDLEWARE 
Python :: print hi in python 
Python :: How to separate characters, Numbers and Special characters from given string with python 
Python :: find if string is substring of another 
Python :: convert set to list python time complexity method 1 
Python :: pandas assign multiple columns 
Python :: install robobrowser python 3 
Python :: Lightbank b2c 
Python :: how to write def 
Python :: Strings Formatting Old Way 
Python :: djangorestframework install command 
Python :: Using iterable unpacking operator * 
Python :: pyqt5 different resolutions 
Python :: importare un foglio di un file excel in python 
Python :: how to make a var in pycode 
Python :: difference between cut and qcut pandas 
Python :: how to make ui dialog pop in front pyqt 
Python :: scatter plot actual vs predicted python 
Python :: how to count to 1billion in python 
Python :: python print functoin 
Python :: etails of the Response object by using help() method 
Python :: Python Old style formatting 
Python :: python read and write lines in file 
Python :: odoo 8 request.session.authenticate 
ADD CONTENT
Topic
Content
Source link
Name
5+8 =