write a python program to find the sum of digits of a given number
Answers
Below are the methods to sum of the digits.
Below are the methods to sum of the digits. Method-1: Using str() and int() methods.: The str() method is used to convert the number to string. The int() method is used to convert the string digit to an integer.
Below are the methods to sum of the digits. Method-1: Using str() and int() methods.: The str() method is used to convert the number to string. The int() method is used to convert the string digit to an integer. Convert the number to string and iterate over each digit in the string and after conerting each digit to integer and add to the sum of the digits in each iteration.
(っ◔◡◔)っ Mark brainliest please
Answer:
Below are the methods to sum of the digits. Method-1: Using str() and int() methods.: The str() method is used to convert the number to string. The int() method is used to convert the string digit to an integer. Convert the number to string and iterate over each digit in the string and after conerting each digit to integer and add to the sum of the digits in each iteration.
Explanation: