Question: Python3 ** It would be helpful if you could write the program in a way that is easy to understand ** Use of Recursion: Programming

Python3

** It would be helpful if you could write the program in a way that is easy to understand **

Use of Recursion:

Programming Problem 1:

(Sum the digits in an integer using recursion)

Write a recursive function that computes the sum of the digits in an integer. Use the following function header:

def sumDigits(n):

For example, sumDigits(234) returns 9. Write a test program that prompts the user to enter an integer and displays the sum of its digits.

Sample Run

Enter an integer: 231498

The sum of digits in 231498 is 27

Analysis:

# Describe the problem including input and output in your own words

Design:

# Describe the major steps (algorithm) for solving the problem

Code:

# Python3 program

Test:

#output

-----------------------------------

Programming Problem 2:

(Print the characters in a string reversely)

Write a recursive function that displays a string reversely on the console using the following header:

def reverseDisplay(value):

For example, reverseDisplay("abcd") displays dcba. Write a test program that prompts the user to enter a string and displays its reversal.

Sample Run

Enter a string: abcd

dcba

Analysis:

# Describe the problem including input and output in your own words

Design:

# Describe the major steps (algorithm) for solving the problem

Code:

# Python3 program

Test:

#output

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!