Fundamentals
Strings
Data Types
def minutes(mins): return '{}:{:02}'.format(*divmod(mins, 60))
function minutes(minutes){var hours = Math.floor(minutes/60);minutes = minutes - hours*60;return hours.toString() + ":" + minutes.toString().padStart(2, 0);}- def minutes(mins):
- return '{}:{:02}'.format(*divmod(mins, 60))
import unittest class TestMinutes(unittest.TestCase): def test_minutes(self): self.assertEquals(minutes(0), "0:00", "better try again"); self.assertEquals(minutes(1), "0:01", "better try again"); self.assertEquals(minutes(18), "0:18", "better try again"); self.assertEquals(minutes(13267), "221:07", "better try again"); self.assertEquals(minutes(985), "16:25", "better try again"); self.assertEquals(minutes(351), "5:51", "better try again"); self.assertEquals(minutes(156113), "2601:53", "better try again");
describe("Solution", function(){it("Did you make the correct conversion?", function(){Test.assertEquals(minutes(0), "0:00", "better try again");Test.assertEquals(minutes(1), "0:01", "better try again");Test.assertEquals(minutes(18), "0:18", "better try again");Test.assertEquals(minutes(13267), "221:07", "better try again");Test.assertEquals(minutes(985), "16:25", "better try again");Test.assertEquals(minutes(351), "5:51", "better try again");Test.assertEquals(minutes(156113), "2601:53", "better try again");});});- import unittest
- class TestMinutes(unittest.TestCase):
- def test_minutes(self):
- self.assertEquals(minutes(0), "0:00", "better try again");
- self.assertEquals(minutes(1), "0:01", "better try again");
- self.assertEquals(minutes(18), "0:18", "better try again");
- self.assertEquals(minutes(13267), "221:07", "better try again");
- self.assertEquals(minutes(985), "16:25", "better try again");
- self.assertEquals(minutes(351), "5:51", "better try again");
- self.assertEquals(minutes(156113), "2601:53", "better try again");