Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Please use Python 2.7.11 to solve the problem Plus Perfect Numbers (Armstrong nu

ID: 3672075 • Letter: P

Question

Please use Python 2.7.11 to solve the problem

Plus Perfect Numbers (Armstrong number) A plus perfect number is a positive integer that is equal to the sum of its own digits each raised to the power of the number of digits. For example, 371 is a plus perfect number since 3**3 + 7**3 + 1**3 = 371. Write a function called "is_plus_perfect" that takes an integer as the input parameter and return whether it is a plus perfect number or not. For example, find_perfect(371) will return "a plus perfect number" find_perfect(300) will return "not a plus perfect number" Define a variable to store the number of digits. Say, digitsN. Initialize digitsN to number of digits in parameter n. Define a variable to store the sun of digits in n each raised to the power of the number of digits. Say, digitPowerSum. Initialize it to zero. For each digit i in n do, Update digitPowerSum such that, digitPowerSum equals to the sum of digitPowerSum in previous iteration and I If digitPowerSum equals to n, Return "a plus perfect number" Else, Return "not a plus perfect number" In addition, write Python statements (in the same script) to take a positive integer from user and display whether that number is Perfect or not using the above function. The user interface of your script may look like as follows:

Explanation / Answer

def is_plus_perfect(n):
     digitN = len(str(n))
     digitPowerSum = 0
     for i in str(n):
        digitPowerSum += int(i) ** digitN
     if(digitPowerSum == n):
        return "a plus perfect number"
     else :
        return "not a plus perfect number"

n = input("Enter a number:")
print "Number ",n," is ",is_plus_perfect(n)