本文整理汇总了Python中solution.sum_of_digits函数的典型用法代码示例。如果您正苦于以下问题:Python sum_of_digits函数的具体用法?Python sum_of_digits怎么用?Python sum_of_digits使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了sum_of_digits函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_sum_of_digits
def test_sum_of_digits(self):
self.assertEqual(43, sum_of_digits(1325132435356))
self.assertEqual(1 + 2 + 3, sum_of_digits(123))
self.assertEqual(6, sum_of_digits(6))
self.assertEqual(1, sum_of_digits(-10))
self.assertEqual(0, sum_of_digits(0))
self.assertEqual(4 + 3 + 5, sum_of_digits(400003005))
示例2: test_with_positive_numbers
def test_with_positive_numbers(self):
self.assertEqual(solution.sum_of_digits(42), 6)
self.assertEqual(solution.sum_of_digits(678732), 33)
示例3: test_1
def test_1(self):
self.assertEqual(43, sum_of_digits(1325132435356))
示例4: test_4
def test_4(self):
self.assertEqual(1, sum_of_digits(-10))
示例5: test_sum_of_digits_1
def test_sum_of_digits_1(self):
self.assertEqual(10, sum_of_digits(37))
示例6: test_sum_of_digits
def test_sum_of_digits(self):
self.assertEqual(43, sum_of_digits(1325132435356))
self.assertEqual(6, sum_of_digits(123))
self.assertEqual(6, sum_of_digits(6))
self.assertEqual(1, sum_of_digits(-10))
示例7: test_one
def test_one(self):
self.assertEqual(solution.sum_of_digits(1325132435356), 43)
示例8: test_three
def test_three(self):
self.assertEqual(solution.sum_of_digits(6), 6)
示例9: test_sum_of_digits_1
def test_sum_of_digits_1(self):
self.assertEqual(43, solution.sum_of_digits(1325132435356))
示例10: test_with_negative_numbers
def test_with_negative_numbers(self):
self.assertEqual(solution.sum_of_digits(-101), 2)
self.assertEqual(solution.sum_of_digits(-10000), 1)
示例11: test_sum_of_digits_4
def test_sum_of_digits_4(self):
self.assertEqual(1, solution.sum_of_digits(-10))
示例12: test_with_numbers_with_odd_number_of_digits
def test_with_numbers_with_odd_number_of_digits(self):
self.assertEqual(solution.sum_of_digits(123456789), 45)
self.assertEqual(solution.sum_of_digits(90000000011), 11)
示例13: test_with_numbers_with_even_number_of_digits
def test_with_numbers_with_even_number_of_digits(self):
self.assertEqual(solution.sum_of_digits(123456), 21)
self.assertEqual(solution.sum_of_digits(89068113), 36)
示例14: test_with_one_digit_numbers
def test_with_one_digit_numbers(self):
self.assertEqual(solution.sum_of_digits(0), 0)
self.assertTrue(solution.sum_of_digits(5), 5)
示例15: test_negative_number
def test_negative_number(self):
self.assertEqual(1, sum_of_digits(-10))