You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Problem: Write a function that calculates the sum of digits of a given integer.
Explanation: This function should take an integer as input and return the sum of its digits. A simple loop can be used to extract each digit.
Function signature: def sum_of_digits(n: int) -> int:
Test cases:
sum_of_digits(1234) should return 10
sum_of_digits(987) should return 24
References: Sum of Digits - Wikipedia Python Integer Methods
The text was updated successfully, but these errors were encountered:
Problem: Write a function that calculates the sum of digits of a given integer.
Explanation: This function should take an integer as input and return the sum of its digits. A simple loop can be used to extract each digit.
Function signature: def sum_of_digits(n: int) -> int:
Test cases:
sum_of_digits(1234) should return 10
sum_of_digits(987) should return 24
References:
Sum of Digits - Wikipedia
Python Integer Methods
The text was updated successfully, but these errors were encountered: