Neural Sync Active
Jan 2026 - Python - Week 6 - Collections 3 - Graded
Registry Synced
Jan 2026 - Python - Week 6 - Collections 3 - Graded
677 words
3 min read
Graded Assignment
Course: Jan 2026 - Python
Collections 3 - Graded
Submission deadline has passed for this assignment
Due Mar 25, 2026 at 11:59 PM IST
Instructions
Use "Test Run" to verify your code with public test cases.
Press "Submit" to have your assignment evaluated.
You can submit your assignment multiple times up until the deadline.
Make sure to submit your final code by the deadline to receive your score.
Summary
100 out of100
Score
Public Tests
3/3 Passed
Submitted on Mar 25, 2026 at 2:33 PM IST
Private Tests
3/3 Passed
Submitted on Mar 25, 2026 at 2:33 PM IST
**Change in eligibility criteria to write oppe2 exam: A5>=40/100 AND A6>=40/100 AND A7>=40/100 AND A8>=40/100. and becoming eligible to give the end term exam.
Element present in exactly one of the two lists**
Given two lists, return a list containing the items that are present in either list but not in both.
Example
>>> in_exactly_one([1, 2, 3], [3, 4, 5]) {1, 2, 4, 5}
Template Code(Click to Expand)
def in_exactly_one(l1: list, l2: list) -> set: ''' Given two lists, return a list containing the items that are present in either list but not in both. Arguments: l1: list - the first list l2: list - the second list Return: set - a set containing the items present in either list 1 or list 2 but not in both Example: >>> in_exactly_one([1, 2, 3], [3, 4, 5]) {1, 2, 4, 5} ''' ...
NOTE: You can use the below tools for working out and debugging. Click to open them in new tab.
Public Tests ( 3/3 )
Case 1
Input:
textis_equal( in_exactly_one([1, 2, 3], [3, 4, 5]), {1, 2, 4, 5} )
Expected Output:
text{1, 2, 4, 5}
Actual Output:
text{1, 2, 4, 5}
Case 2
Input:
textis_equal( in_exactly_one( ['apple', 'ball', 'cat'], ['ball', 'cat', 'dog'] ), {'apple', 'dog'} )
Expected Output:
text{'apple', 'dog'}
Actual Output:
text{'apple', 'dog'}
Case 3
Input:
textis_equal( in_exactly_one( list(range(1,10)), list(range(5,15)) ), {*range(1,5),*range(10,15)} )
Expected Output:
text{1, 10, 11, 12, 13, 14, 2, 3, 4}
Actual Output:
text{1, 10, 11, 12, 13, 14, 2, 3, 4}
Private Tests ( 3/3 )
Case 1
Input:
textis_equal( in_exactly_one( [55, 62, 12, 22], [21, 35, 45] ), {35, 12, 45, 21, 22, 55, 62} )
Expected Output:
text{12, 21, 22, 35, 45, 55, 62}
Actual Output:
text{12, 21, 22, 35, 45, 55, 62}
Case 2
Input:
textis_equal( in_exactly_one( ['apple', 'ball', 'cat'], ['apple', 'ball', 'cat'] ), set() )
Expected Output:
text{}
Actual Output:
text{}
Case 3
Input:
textis_equal( in_exactly_one( list(range(100,111)), list(range(102,105)) ), {100,101,*range(105,111)} )
Expected Output:
text{100, 101, 105, 106, 107, 108, 109, 110}
Actual Output:
text{100, 101, 105, 106, 107, 108, 109, 110}
💻 IITM Official Solution
pythondef in_exactly_one(l1: list, l2: list) -> set: ''' Given two lists, return a list containing the items that are present in either list but not in both. Arguments: l1: list - the first list l2: list - the second list Return: set - a set containing the items present in either list 1 or list 2 but not in both Example: >>> in_exactly_one([1, 2, 3], [3, 4, 5]) {1, 2, 4, 5} ''' return set(l1) ^ set(l2)
💻 My Submitted Code
pythondef in_exactly_one(l1: list, l2: list) -> set: ''' Given two lists, return a list containing the items that are present in either list but not in both. Arguments: l1: list - the first list l2: list - the second list Return: set - a set containing the items present in either list 1 or list 2 but not in both Example: >>> in_exactly_one([1, 2, 3], [3, 4, 5]) {1, 2, 4, 5} ''' ... return set(l1) ^ set(l2)