Neural Sync Active
Jan 2026 - Python - Week 10 - GrPA 1
Registry Synced
Jan 2026 - Python - Week 10 - GrPA 1
579 words
3 min read
GrPA 1
Course: Jan 2026 - Python
GrPA 1
Submission deadline has passed for this assignment
Due Apr 22, 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
2/2 Passed
Submitted on Apr 22, 2026 at 7:10 PM IST
Private Tests
5/5 Passed
Submitted on Apr 22, 2026 at 7:10 PM IST
Create a class named Calculator that has the following specification:
Attributes
(1) a: int, we shall call this the first attribute
(2) b: int, we shall call this the second attribute
Methods
(1) __init__: accept two arguments a and b, assign them to the corresponding attributes
(2) add: return the sum of the two attributes
(3) multiply: return the product of the two attributes
(4) subtract: subtract the second attribute from the first and return this value
(5) quotient: return the quotient when the first attribute is divided by the second attribute
(6) remainder: return the remainder when the first attribute is divided by the second
(1) Each test case corresponds to one or more method calls. We will use C to denote the name of the object.
(2) You do not have to accept input from the user or print output to the console. You just have to define the class based on the specifications given in the question.
Public Tests ( 2/2 )
Case 1
Input:
textpublic Calculator(3, 5) C.add()
Expected Output:
text8
Actual Output:
text8
Case 2
Input:
textpublic Calculator(5, 10) C.quotient()
Expected Output:
text0
Actual Output:
text0
Private Tests ( 5/5 )
Case 1
Input:
textprivate Calculator(3, 9) C.multiply()
Expected Output:
text27 You have defined the class correctly.
Actual Output:
text27 You have defined the class correctly.
Case 2
Input:
textprivate Calculator(5, 15) C.subtract()
Expected Output:
text-10 You have defined the class correctly.
Actual Output:
text-10 You have defined the class correctly.
Case 3
Input:
textprivate Calculator(19, 3) C.remainder()
Expected Output:
text1 You have defined the class correctly.
Actual Output:
text1 You have defined the class correctly.
Case 4
Input:
textprivate Calculator(15, 5) C.quotient()
Expected Output:
text3 You have defined the class correctly.
Actual Output:
text3 You have defined the class correctly.
Case 5
Input:
textprivate Calculator(10, 50) C.add()
Expected Output:
text60 You have defined the class correctly.
Actual Output:
text60 You have defined the class correctly.
💻 IITM Official Solution
pythonclass Calculator: def __init__(self, a, b): self.a, self.b = a, b def add(self): return self.a + self.b def multiply(self): return self.a * self.b def subtract(self): return self.a - self.b def quotient(self): return self.a // self.b def remainder(self): return self.a % self.b
💻 My Submitted Code
pythonclass Calculator: def __init__(self, a, b): self.a = a self.b = b def add(self): return self.a + self.b def multiply(self): return self.a * self.b def subtract(self): return self.a - self.b def quotient(self): return self.a // self.b def remainder(self): return self.a % self.b