Question: 1-Write a function nice_number, which has no argument, but asks the user to input on the keyboard a positive number. If the input of the

1-Write a function nice_number, which has no argument, but asks the user to input on the keyboard a positive number. If the input of the user contains any symbol other than digits 0,...,9, the function should return a string "Invalid input." Otherwise, if the sum of the digits entered is a prime number the function should return the string "This is a nice number, thank you." In all other cases, the function should return "Thanks."

2-Write a function is_perfect, which accepts a single integer as input. If the input is not positive, the function should return a string "Invalid input." If the input is positive, the function should return True if the input is a perfect number and False otherwise.

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!