Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

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

Students also viewed these Databases questions