Neural Sync Active
jan-2026-python-week-8-grpa-2
Registry Synced
jan-2026-python-week-8-grpa-2
515 words
3 min read
GrPA 2
Course: Jan 2026 - Python
GrPA 2
Due Apr 08, 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
- out of100
Score
Public Tests
0/0 Passed
Private Tests
0/0 Passed
**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.
**
You are given two non-empty text files file1 and file2 that have f1 and f2 lines respectively. Each file is a collection of ten-digit phone numbers, one number per line. It is also known that 0<f1≤f2.
The following relations are defined on these two files:
- Subset: file1 is a subset of file2 if the phone number in the ith line of file1 is equal to the number in the ith line of file2, for 1≤i≤f1, and f1<f2.
- Equal: file1 is equal to file2 if the phone number in the ith line of file1 is equal to the number in the ith line of file2 for 1≤i≤f1, and f1=f2.
Write a function named relation that accepts these two text files as arguments. It should return the string Subset if file1 is a subset of file2. It should return Equal if file1 is equal to file2. If both these conditions are not satisfied, it should return the string No Relation.
(1) file1 and file2 are string variables that hold the names of the two files. For example, in the first test case, it is file1 = 'public_1_1.txt' and file2 = 'public_1_2.txt'.
(2) You do not have to accept input from the console or print the output to the console. You just have to write the function definition.
(3) The strings '9876543210' and '9876543210\n' are not the same, though the phone numbers are the same. So, strip the strings of all new lines using the strip method before checking for equality of two lines across the files.
Public Tests ( 0/0 )
Case 1
Input:
text100 public_1_1.txt public_1_2.txt
Case 1
Expected Output:
textSubset
Case 2
Input:
text300 public_2_1.txt public_2_2.txt
Case 2
Expected Output:
textNo Relation
Case 3
Input:
text500 public_3_1.txt public_3_2.txt
Case 3
Expected Output:
textEqual
🔒 Private Tests ( 0/0 )
This test case group is locked and will be revealed after the deadline.
💻 IITM Official Solution
Solution code is currently locked and will be available after the deadline.
💻 My Submitted Code
pythondef relation(file1, file2): """ Determine the relationship between two files Arguments: file1, file2: strings, paths to two files Return: string: 'Equal', 'Subset' or 'No Relation' """