Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Concepts International Edition

Authors: David M. Kroenke

6th Edition International Edition

0133098222, 978-0133098228

More Books

Students also viewed these Databases questions

Question

Understand how customers respond to effective service recovery.

Answered: 1 week ago

Question

Know the principles of effective service recovery systems.

Answered: 1 week ago