NEEDS TO BE IN PYTHON!: Program Behavior The program will repeatedly read numbers entered by the user and respond accordingly. Below is a sample run of the program. User input is shown in blue. A value of -1 is used as a sentinel value as the indication the user wants to end the program. Your program should include the following functions: get_number - This function reads an integer from the user, validates it, and returns it. The function should reprompt the user as many times as necessary until the user enters a positive integer or the sentinel value. This function accepts no arguments. is_pronic - This predicate function accepts an integer argument and returns True if the argument is a pronic number and False otherwise. The function should check to see if the product of any two consecutive integers between 1 and a max value equals the argument. The max value checked should be the ceiling of the square root of the argument (any consecutive pair past that max value will be greater than the argument and therefore need not be checked). Use the max.ceil and max.sqrt functions. is_perfect - This predicate function accepts an integer argument and returns True if the argument is a perfect number and False otherwise. The function should check to see if the sum of add up all integer divisors of the argument, except itself, equals the argument. main - This function represents the main program. It contains the loop that processes multiple values, calling the other functions as needed. Call the get_number function initially to get the first input value, then loop to process the value and get the next one,
NEEDS TO BE IN PYTHON!:
Program Behavior The program will repeatedly read numbers entered by the user and respond accordingly. Below is a sample run of the program. User input is shown in blue. A value of -1 is used as a sentinel value as the indication the user wants to end the program.
Your program should include the following functions:
get_number - This function reads an integer from the user, validates it, and returns it. The function should reprompt the user as many times as necessary until the user enters a positive integer or the sentinel value. This function accepts no arguments.
is_pronic - This predicate function accepts an integer argument and returns True if the argument is a pronic number and False otherwise. The function should check to see if the product of any two consecutive integers between 1 and a max value equals the argument. The max value checked should be the ceiling of the square root of the argument (any consecutive pair past that max value will be greater than the argument and therefore need not be checked). Use the max.ceil and max.sqrt functions.
is_perfect - This predicate function accepts an integer argument and returns True if the argument is a perfect number and False otherwise. The function should check to see if the sum of add up all integer divisors of the argument, except itself, equals the argument.
main - This function represents the main program. It contains the loop that processes multiple values, calling the other functions as needed. Call the get_number function initially to get the first input value, then loop to process the value and get the next one,
Trending now
This is a popular solution!
Step by step
Solved in 4 steps with 2 images