Question: Python Programming Consider this recursive function that computes the sum of all digits of an integer (in base 10): def digits_sum(n): if n < 10:

Python Programming

Consider this recursive function that computes the sum of all digits of an integer (in base 10):

def digits_sum(n):

if n < 10:

return n

... part A ... # missing. You find out what's on this line.

The recursive case is missing. Which of the following options is the correct line that substitutes part A ?

1. return (n % 10) + digits_sum(n / 10)

2. return digits_sum(n % 10) + (n % 10)

3. return (n % 10) + n // 10

4. return (n // 10) + digits_sum(n % 10)

5. return (n % 10) + digits_sum(n // 10)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!