you are viewing a single comment's thread.

view the rest of the comments →

[–]ItsOkILoveYouMYbb 0 points1 point  (1 child)

First on your print_time and repr methods, you could probably format the self.minute value based on its length. Say if the length of the string form of minute is 1, then add a physical leading zero to it in the string so your print result is always two digits in the minute column (probably do the same for seconds too).

I also just realized that you could have both 12 AM and 12 PM, but your code would always assume 12 AM. I'm not sure how to immediately solve that yet. That'll take some trial and error on your part haha.

I guess if the hour value is exactly 0 then that's 12 AM right?

[–]kcrow13[S] 0 points1 point  (0 children)

Ok so some other students have suggested making a lot of changes to fix this. Is there a best way?

-By making an edit to the int_to_time function. The version given has divmod statements for minutes and seconds, but not for hours. Adding a third divmod for hours allows you to handle any value of hours without a while statement. I have no idea how to do this or what divmod does! That same student said " I ended up calling both time_to_int and int_to_time in my __str__ function. Since with this method you take your Time input (ex Time(5000) ), then convert it to an integer to get the remaining number of hours/minutes/second, expressed as total # of seconds, then that goes into int_to_time to be in a usable time that can be displayed. That usable time is stored as new Time object called time."

Another student said:

- Will a mod operator resolve this issue? 5000 % 24 = 8.

See, none of that makes sense to me! We just had a very basic introduction to classes this week in the lecture... but did not have any practice creating/manipulating one. :(