id/email
password
forgot password | create account
about | help | code help+videos | done | prefs
CodingBat code practice

 

david.white@denison.edu cs111fall2019 > sumDigits
prev  |  next  |  chance

Write a function sumDigits(number, numDigits) that returns the sum of the individual digits in a parameter number that has numDigits digits. For example, sumDigits(1234, 4) should return the value 1 + 2 + 3 + 4 = 10. (Hint: use a for loop and integer division (// and %).)


sumDigits(324, 3) → 9
sumDigits(1976, 4) → 23
sumDigits(19760, 5) → 23

...Save, Compile, Run (ctrl-enter)

def sumDigits(number, digits):

Editor font size %:
Shorter output


Forget It! -- delete my code for this problem

Progress graphs:
 Your progress graph for this problem
 Random user progress graph for this problem
 Random Epic Progress Graph

Python Help

Copyright Nick Parlante 2017 - privacy