Registry Synced

Jan 2026 - Python - Week 10 - GrPA 4

1050 words
5 min read

Graded Assignment

Course: Jan 2026 - Python
GrPA 4
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
3/3 Passed
Submitted on Apr 22, 2026 at 7:11 PM IST
Private Tests
6/6 Passed
Submitted on Apr 22, 2026 at 7:11 PM IST

Create a class Time with the following specification:
Attributes
time: int, represents time in seconds
Methods
(1) __init__: accept time in seconds as an argument and assign it to the corresponding attribute
(2) seconds_to_minutes: convert the value of time into minutes and return a string in the format: "<minutes> min <seconds> sec". For example: if the value of the attribute time is 170170, this method should return the string "2 min 50 sec"
(3) seconds_to_hours: convert the value of time into hours and return a string in the format: "<hours> hrs <minutes> min <seconds> sec". For example: if the value of the attribute time is 1089010890, this method should return the string "3 hrs 1 min 30 sec"
(4) seconds_to_days: convert the value of time into days and return a string in the format: "<days> days <hours> hrs <minutes> min <seconds> sec". For example: if the value of the attribute time is 8646086460, this method should return the string "1 days 0 hrs 1 min 0 sec"

(1) Each test case corresponds to one or more method calls. We will use T 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 ( 3/3 )

Case 1

Input:
text
public
Time(35)
Expected Output:
text
0 min 35 sec

0 hrs 0 min 35 sec

0 days 0 hrs 0 min 35 sec
Actual Output:
text
0 min 35 sec

0 hrs 0 min 35 sec

0 days 0 hrs 0 min 35 sec

Case 2

Input:
text
public
Time(6582)
Expected Output:
text
109 min 42 sec

1 hrs 49 min 42 sec

0 days 1 hrs 49 min 42 sec
Actual Output:
text
109 min 42 sec

1 hrs 49 min 42 sec

0 days 1 hrs 49 min 42 sec

Case 3

Input:
text
public
Time(257865)
Expected Output:
text
4297 min 45 sec

71 hrs 37 min 45 sec

2 days 23 hrs 37 min 45 sec
Actual Output:
text
4297 min 45 sec

71 hrs 37 min 45 sec

2 days 23 hrs 37 min 45 sec

Private Tests ( 6/6 )

Case 1

Input:
text
private
Time(36000)
Expected Output:
text
600 min 0 sec

10 hrs 0 min 0 sec

0 days 10 hrs 0 min 0 sec

You have defined the class correctly.
Actual Output:
text
600 min 0 sec

10 hrs 0 min 0 sec

0 days 10 hrs 0 min 0 sec

You have defined the class correctly.

Case 2

Input:
text
private
Time(654768)
Expected Output:
text
10912 min 48 sec

181 hrs 52 min 48 sec

7 days 13 hrs 52 min 48 sec

You have defined the class correctly.
Actual Output:
text
10912 min 48 sec

181 hrs 52 min 48 sec

7 days 13 hrs 52 min 48 sec

You have defined the class correctly.

Case 3

Input:
text
private
Time(43455444)
Expected Output:
text
724257 min 24 sec

12070 hrs 57 min 24 sec

502 days 22 hrs 57 min 24 sec

You have defined the class correctly.
Actual Output:
text
724257 min 24 sec

12070 hrs 57 min 24 sec

502 days 22 hrs 57 min 24 sec

You have defined the class correctly.

Case 4

Input:
text
private
Time(1257865)
Expected Output:
text
20964 min 25 sec

349 hrs 24 min 25 sec

14 days 13 hrs 24 min 25 sec

You have defined the class correctly.
Actual Output:
text
20964 min 25 sec

349 hrs 24 min 25 sec

14 days 13 hrs 24 min 25 sec

You have defined the class correctly.

Case 5

Input:
text
private
Time(5000)
Expected Output:
text
83 min 20 sec

1 hrs 23 min 20 sec

0 days 1 hrs 23 min 20 sec

You have defined the class correctly.
Actual Output:
text
83 min 20 sec

1 hrs 23 min 20 sec

0 days 1 hrs 23 min 20 sec

You have defined the class correctly.

Case 6

Input:
text
private
Time(100000)
Expected Output:
text
1666 min 40 sec

27 hrs 46 min 40 sec

1 days 3 hrs 46 min 40 sec

You have defined the class correctly.
Actual Output:
text
1666 min 40 sec

27 hrs 46 min 40 sec

1 days 3 hrs 46 min 40 sec

You have defined the class correctly.

💻 IITM Official Solution

python
class Time:
    def __init__(self, time):
        self.time = time
    def seconds_to_minutes(self):
        self.minutes = self.time // 60
        self.seconds = self.time % 60
        return f'{self.minutes} min {self.seconds} sec'

    def seconds_to_hours(self):
        self.seconds_to_minutes()
        self.hours = self.minutes // 60
        self.minutes = self.minutes % 60
        return f'{self.hours} hrs {self.minutes} min {self.seconds} sec'

    def seconds_to_days(self):
        self.seconds_to_hours()
        self.days = self.hours // 24
        self.hours = self.hours % 24
        return f'{self.days} days {self.hours} hrs {self.minutes} min {self.seconds} sec'


💻 My Submitted Code

python
class Time:
    def __init__(self, time):
        self.time = time
    def seconds_to_minutes(self):
        m = self.time // 60
        s = self.time % 60
        return f"{m} min {s} sec"
    def seconds_to_hours(self):
        h = self.time // 3600
        m = (self.time % 3600) // 60
        s = self.time % 60
        return f"{h} hrs {m} min {s} sec"
    def seconds_to_days(self):
        d = self.time // 86400
        h = (self.time % 86400) // 3600
        m = (self.time % 3600) // 60
        s = self.time % 60
        return f"{d} days {h} hrs {m} min {s} sec"

Document Outline
Table of Contents
System Normal // Awaiting Context

Intelligence Hub

Navigate the knowledge graph to generate context. The Hub adapts dynamically to surface backlinks, related notes, and metadata insights.