While learning Python from http://www.learnpython.org/en/Sets I encountered the notion of symmetric_difference between sets. I thought it gave the same output as 'exclusive or' operations on sets. How is it different?
What is Python symmetric_difference and how is it different from XOR operation?
4.5k Views Asked by Huxwell At
2
There are 2 best solutions below
2
mik01aj
On
Yes, it is pretty much the same, just XOR is an operation on booleans, and symmetric_difference is an operation on sets. Actually, even your linked documentation page says this:
To find out which members attended only one of the events, use the "symmetric_difference" method
You can also see this more detailed mathematical explanation about relationship between logical XOR and symmetric difference on sets.
Related Questions in PYTHON
- How to store a date/time in sqlite (or something similar to a date)
- Instagrapi recently showing HTTPError and UnknownError
- How to Retrieve Data from an MySQL Database and Display it in a GUI?
- How to create a regular expression to partition a string that terminates in either ": 45" or ",", without the ": "
- Python Geopandas unable to convert latitude longitude to points
- Influence of Unused FFN on Model Accuracy in PyTorch
- Seeking Python Libraries for Removing Extraneous Characters and Spaces in Text
- Writes to child subprocess.Popen.stdin don't work from within process group?
- Conda has two different python binarys (python and python3) with the same version for a single environment. Why?
- Problem with add new attribute in table with BOTO3 on python
- Can't install packages in python conda environment
- Setting diagonal of a matrix to zero
- List of numbers converted to list of strings to iterate over it. But receiving TypeError messages
- Basic Python Question: Shortening If Statements
- Python and regex, can't understand why some words are left out of the match
Related Questions in SET
- mondrian3 set by aggregate
- Produce a combination of all permutations for 4 groups of data with 4 unique values contained
- How to find the difference between two python files and write output with file source information
- Is there a problem with my code? Finding null pointer Exception
- The difference between set definitions in Python
- Leetcode BFS Set insertion giving TLE (200. Number of Islands)
- set.find() not working for ordered multiset
- TinyMCE custom toolbar button to set CSS property of selected text
- Find a bit with no duplicates among multiple bits in Java
- Algorithm for comparing two sets of sets
- Order of a set in Python
- Proof on inductive sets
- Remove all elements from a set greater than a number
- Trying to prove a set to be the union of its singleton sets in Dafny
- Declaring a set of a set in Mosel
Related Questions in XOR
- Negate every bit value of a binary in C
- XOR Hex and ASCII
- XOR Encryption in C with key
- Operating XOR over a defined set of iterating matrices in python
- How to model an exclusive or in OWL?
- XOR with NEAT Algorithm
- XORing all values of a (2d) numpy array together
- XOR operator problems in C
- XOR command fails
- Is it possible to reverse the XOR of multiple variables?
- Can we replace XOR with multiply-add?
- Correctly embedding and extracting Unicode data from an image
- Execution Time Difference between two bit-wise differential execution
- How to Improve XORing of large uint64 arrays?
- Backpropagation in Neural Network for XOR data
Related Questions in SYMMETRIC-DIFFERENCE
- How to find the difference between two python files and write output with file source information
- How to find symmetrical difference using JavaScript?
- Symmetric Difference Recursion Function is returning "UNDEFINED"
- Can I use update method of set in Python to merge two set (x-y) and (y-x)?
- Efficiently compute xor / symmetric difference of many sets (list of sets)
- What is the best effective way to get symmetric difference between two strings(in python)?
- Finding symmetric difference of two lists of objects
- How can the symmetric difference between two lists be obtained?
- how to reduce the key number used in symmetric encryption
- Python: Symmetrical Difference Between List of Sets of Strings
- symmetric_difference Output as Two Separate Lists
- convert a set of tuples into a numpy array of lists in python
- Python sets: difference() vs symmetric_difference()
- How to efficiently find identical indices in multiple dataframes
- Comparing 2 arrays for differences (find symmetric difference)
Trending Questions
- UIImageView Frame Doesn't Reflect Constraints
- Is it possible to use adb commands to click on a view by finding its ID?
- How to create a new web character symbol recognizable by html/javascript?
- Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
- Heap Gives Page Fault
- Connect ffmpeg to Visual Studio 2008
- Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
- How to avoid default initialization of objects in std::vector?
- second argument of the command line arguments in a format other than char** argv or char* argv[]
- How to improve efficiency of algorithm which generates next lexicographic permutation?
- Navigating to the another actvity app getting crash in android
- How to read the particular message format in android and store in sqlite database?
- Resetting inventory status after order is cancelled
- Efficiently compute powers of X in SSE/AVX
- Insert into an external database using ajax and php : POST 500 (Internal Server Error)
Popular # Hahtags
Popular Questions
- How do I undo the most recent local commits in Git?
- How can I remove a specific item from an array in JavaScript?
- How do I delete a Git branch locally and remotely?
- Find all files containing a specific text (string) on Linux?
- How do I revert a Git repository to a previous commit?
- How do I create an HTML button that acts like a link?
- How do I check out a remote Git branch?
- How do I force "git pull" to overwrite local files?
- How do I list all files of a directory?
- How to check whether a string contains a substring in JavaScript?
- How do I redirect to another webpage?
- How can I iterate over rows in a Pandas DataFrame?
- How do I convert a String to an int in Java?
- Does Python have a string 'contains' substring method?
- How do I check if a string contains a specific word?
There is no difference. XORing sets works by calling the
symmetric_differencefunction. This is from the implementation of sets in sets.py:As you can see the XOR implementation makes sure that you are indeed working on sets only, but otherwise there are no differences.