Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Need a Python program that determines which of the 3 two-digit numbers input by the user is divisible by the sum of its digits Your

Need a Python program that determines which of the 3 two-digit numbers input by the user is divisible by the sum of its digits

Your solution must include 3 functions

  1. that input 3 numbers. Validate that each number is a positive number. If a negative number is input terminate the script. Use the example shown in this test program Download the test program
  2. Find the sum of the digits for the input number. The function takes in one number as the argument and returns the sum.
  3. Determine which numbers are divisible by their sum. Divisibility indicates that the remainder after division is 0. You must call this function from main() and pass in all the input numbers. Call the function from #B above pass in each number and get the sum.  Note: The function to calculate the sum must be called 3 times. Determine divisibility for each number by using its corresponding sum. If divisible, increment a counter value. After all three numbers have been processed, return the counter value to main().
  4. A main function that calls the above functions in the right sequence. The return value from the function in #C above must be displayed using a descriptive sentence as shown in the example below. Use the string format using the f string to construct your final output statement.

Don't forget to call main() as the last line in your script to enable it to be executed

 Example:

Input first number: 27

Input first number: 12

Input first number: 33

sum of digits for first number: 9

sum of digits for first number: 3

sum of digits for first number: 6

Final output should be as follows:

2 of the input numbers are divisible by the sum of their digits.

Step by Step Solution

3.44 Rating (163 Votes )

There are 3 Steps involved in it

Step: 1

def inputpositi... 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

Principles Of Information Security

Authors: Michael E. Whitman, Herbert J. Mattord

7th Edition

035750643X, 978-0357506431

More Books

Students also viewed these Programming questions