Need a Python program that determines which of the 3 two-digit numbers input by the user is
Fantastic news! We've Found the answer you've been seeking!
Question:
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
- 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
- Find the sum of the digits for the input number. The function takes in one number as the argument and returns the sum.
- 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().
- 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.
Related Book For
Principles Of Information Security
ISBN: 9780357506431
7th Edition
Authors: Michael E. Whitman, Herbert J. Mattord
Posted Date: