About 2,650,000 results
Open links in new tab
  1. python - Sum of digits of a number using While - Stack Overflow

    Oct 16, 2014 · How can I make python sum 123 to give 6 using while? def calc_soma(num): ns = str(num) soma = 0 while soma < len(ns): soma = eval(ns[soma]) soma = soma + 1 return soma

  2. Python Program to Find Sum of Digits of a Number - Tutorial …

    In this section, we discuss how to write a Python Program to Find the Sum of Digits of a Number using a While Loop, for loop, Functions, and Recursion. This program allows the user to enter …

  3. Sum the Digits of a Given Number – Python | GeeksforGeeks

    Feb 24, 2025 · Sum of number digits in list involves iterating through each number in the list, breaking the number into its individual digits and summing those digits. The simplest way to do …

  4. Python:How to make the sum of the values of a while loop store …

    Aug 23, 2012 · I'm doing a tutorial about while loops on Codeacademy "Click here!" , but I've gotten stuck on this part: Write a while loop which stores into " theSum " the sum of the first 10 …

  5. Sum of Digits of a Number in Python - Python Guides

    Aug 25, 2024 · Here, I will explain different methods to calculate the sum of digits of a number in Python with examples. To calculate the sum of digits of a number in Python using a while loop, …

  6. python - Trying to calculate the sum of numbers using while loop ...

    Oct 26, 2018 · I'm trying to calculate the sum of multiple numbers using a while loop. When a negative number is entered the sum of the numbers should be printed. When I run the code all …

  7. Python Program to Find Sum of all Digits of Given Number Using While Loop

    The program takes an input of a number and uses a while loop to find the sum of all its digits. The while loop continues until the number becomes zero. In each iteration, the last digit of the …

  8. Sum of Digits Program in Python - Sanfoundry

    Using a while loop, get each digit of the number and add the digits to a variable. 3. Print the sum of the digits of the number. 4. Exit. Here is the source code of the Python Program to find the …

  9. Sum of Digits of a Number in Python - Know Program

    In this post, we will write a program to find the sum of digits of an integer number in Python. We can use the while loop to write the program. We can also develop a Python program to …

  10. Python Program to find Sum of Digits | CodeToFun

    Oct 31, 2024 · Run the script to find the sum of digits for the specified number. The program defines a function sum_of_digits that takes an integer number as input and returns the sum of …

Refresh