1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
wlad13 [49]
3 years ago
12

In number theory, a perfect number is a positive integer that is equal to the sum of its proper positive divisors, that is, the

sum of its positive divisors excluding the number itself (also known as its aliquot sum). Equivalently, a perfect number is a number that is half the sum of all of its positive divisors (including itself). Write a Python3 program to check if a user-entered number is a perfect number or not. Use exception handling to handle invalid inputs.
Computers and Technology
1 answer:
rusak2 [61]3 years ago
8 0

Answer:

Explanation:

def the_perfect(n):

  try: #exception handling if n is a negative number

       n > 0

   except: #return -1 if the error is reached

       return -1

  else:

        total = 0

        for i in range(1, n): #for loop from 1 to the target number

           if n % i == 0:

               total += i

   return total == n  #should return true if number is perfect number

print(perfect_number(8))

You might be interested in
What is the main storage location of a computer
gogolik [260]
I'm pretty sure its the hard drive, that's the main storage
8 0
3 years ago
Once the CPU has fetched the data requested, what are the next steps in the process?
Bezzdna [24]

Answer:

D. decode execute

Explanation:

3 0
3 years ago
A __________ is a thorough examination of each aspect of a network to determine how it may be compromised.
Lunna [17]

Answer:

A posture assessment. :3

3 0
3 years ago
Discuss briefly general-purpose graphicsprimitives that contain 2D graphics library.
Zina [86]

Answer:

  General purpose graphics primitives that contain 2D graphic library as, it is used in graphics processing unit which typically manage computation for computer graphics. Graphic primitives contain basic element such as lines and curves. Modern 2D computer graphic system that operate with primitives which has lines and shapes. All the elements of graphic are formed from primitives.

8 0
3 years ago
I am not a living being, I am a cylindrical shape that has three to eight sides. I never die. I can build anything again. What i
Setler79 [48]

Answer:

A shape

Explanation:

4 0
3 years ago
Other questions:
  • Which is true about POP3 and IMAP for incoming email?
    6·1 answer
  • what is it called when you are biying and selling products via electronic channels such as the internet​
    13·2 answers
  • Which information is necessary to determine an object's speed?
    13·1 answer
  • Why should the data in a reservation system that is constantly being updated be stored on a magnetic disk instead of a CD or DVD
    15·1 answer
  • While doing research on the Internet, what kind of website should you avoid because the information may be biased? A) .org. B) .
    15·2 answers
  • What natural resource are available on the coast but not somewhereelse
    13·1 answer
  • Emma lives in Pennsylvania, what climate does she live in?
    7·1 answer
  • What is the by stander effect
    9·1 answer
  • Question # 2
    7·1 answer
  • When would the Jerusalem virus attack?<br> 1. Friday the 13th<br> 2. Wednesday the 13th
    13·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!