In (3) def isPerfect (x) ***Returns whether or not the given number x is perfect. A number is said to be perfect if it is equal to the sum of all its factors (for obvious reasons the list of factors being considered does not include the number itself). Example: 63+2+1, hence 6 is perfect. Example: 20 is another example since 1+2 +4 + 7 + 14 in 28. Note, the number 1 is not a perfect number. *** your code here Sum - 0 for i in range(1, x) LE(0)1 Sun Bum + 1 if (Bum=-X) else! print(" td is a Perfect Number 1x) print(td is not a Perfect Number" 1x) print (isPerfect (6)) File "cipython-input-3-b9df3e539048", line 15 for i in range(1, x) IndentationError: unexpected indent In 1411 perfect numbers 16, 28, 496, 8126, 335503361 for i in perfect numbers: assert true (isPerfect (i), str(i)+ is perfect') not perfect numbers (2, 3, 4, 5, 7, 8, 9, 10, 495, 8127, 8129, 335503351 for i in not perfect numbers assert true (not (isPerfect (i)), str(i) is not perfect') test existence of doestring assert true(len (isPerfect._doc_) 1, "there is no docstring for isPerfect") print("Success!")

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter8: Arrays And Strings
Section: Chapter Questions
Problem 21PE
icon
Related questions
Question
In [3]: def isPerfect (x):
***Returns whether or not the given number x is perfect.
A number is said to be perfect if it is equal to the sum of all its
factors (for obvious reasons the list of factors being considered does
not include the number itself).
Example: 6 = 3 + 2 + 1, hence 6 is perfect.
Example: 28 is another example since 1 + 2 + 4 + 7 + 14 is 28.
Note, the number 1 is not a perfect number.
your code here
Sum - 0
for i in range(1, x)
if(x1= 0):
Sun - Sum + 1
if (Sum X)I
print(" td is a Perfect Number" 1x)
print(" td is not a Perfect Number 1x)
else:
print (isPerfect (6))
File "cipython-input-3-b9df3e539e48", line 15
for i in range(1, x):
IndentationError: unexpected indent
In [411 perfect numbers [6, 28, 496, 8128, 335503361
for i in perfect_numbers:
assert true (isPerfect (i), str(i) + is perfect')
not_perfect_numbers [2, 3, 4, 5, 7, 8, 9, 10,
495, 8127, 8129,
335503351
for i in not perfect_numbers:
assert true (not (isPerfect (i)), str(i) is not perfect')
#test existence of doestring
assert true (len (isPerfect._doc_) > 1, "there is no docstring for isPerfect")
print("Success!")
Transcribed Image Text:In [3]: def isPerfect (x): ***Returns whether or not the given number x is perfect. A number is said to be perfect if it is equal to the sum of all its factors (for obvious reasons the list of factors being considered does not include the number itself). Example: 6 = 3 + 2 + 1, hence 6 is perfect. Example: 28 is another example since 1 + 2 + 4 + 7 + 14 is 28. Note, the number 1 is not a perfect number. your code here Sum - 0 for i in range(1, x) if(x1= 0): Sun - Sum + 1 if (Sum X)I print(" td is a Perfect Number" 1x) print(" td is not a Perfect Number 1x) else: print (isPerfect (6)) File "cipython-input-3-b9df3e539e48", line 15 for i in range(1, x): IndentationError: unexpected indent In [411 perfect numbers [6, 28, 496, 8128, 335503361 for i in perfect_numbers: assert true (isPerfect (i), str(i) + is perfect') not_perfect_numbers [2, 3, 4, 5, 7, 8, 9, 10, 495, 8127, 8129, 335503351 for i in not perfect_numbers: assert true (not (isPerfect (i)), str(i) is not perfect') #test existence of doestring assert true (len (isPerfect._doc_) > 1, "there is no docstring for isPerfect") print("Success!")
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Knowledge Booster
Function Arguments
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning