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
Write a program that uses two input statements to get two words as input. Then, print the words on one line separated by a space
Shkiper50 [21]

word1 = input("Enter a word: ")

word2 = input("Enter a word: ")

print(word1 + " " + word2)

I hope this helps!

6 0
3 years ago
When you use the .net data provider objects to retrieve data from a database, you can store the data in an object called a?
Ainat [17]
Data set is the object that you can store data.
6 0
3 years ago
________ refers to the ability to identify the person or entity with whom you are dealing on the Internet. Question 41 options:
sleet_krkn [62]
C) Authenticity

Authenticity refers to the ability to identify the person or entity whom you are dealing on the internet.
7 0
4 years ago
PLEASEEEE HELPPP
zavuch27 [327]
<span>C. real-time operating system</span>
6 0
3 years ago
At the settings window, the app buttons below the background thumbnails are used to change the
Vera_Pavlovna [14]
B because usually when you start a game it says it
4 0
3 years ago
Other questions:
  • Once in debt, ________ is your companion every minute of the day and night, you cannot shun it or slip away from it . . . and wh
    10·1 answer
  • When you buy an Xbox 360 can you play online for free
    12·2 answers
  • Joe sends a scathing e-mail to his boss regarding increased work hours. Joe tries to deny sending the e-mail, but is unable to d
    9·1 answer
  • User authentication is a procedure that allows communicating parties to verify that the contents of a received message have not
    12·1 answer
  • A) A cable that is mainly used in the cable television network
    11·1 answer
  • What helps companies and organizations to target masses of people, provide 24/7 services, and deliver better marketing in a chea
    6·1 answer
  • The frequency of a sine wave is defined as:
    8·1 answer
  • an IPv6 packet has a 40 byte base header, a 20 byte destination options extension header (which is not used for routing) and 200
    5·1 answer
  • Network in which every computer is capable of playing the role of the client, server or both at the same time is called *
    6·1 answer
  • A(n) _____ is a network connection device that can build tables that identify addresses on each network.
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!