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 approximate boiling point
lesantik [10]
For water the approximate boiling point is 100 degrees Celsius.
<span />
4 0
3 years ago
A=1/2h(a+b) solve for h
devlian [24]

A=1/2h(a+b)

1/2 can be said as 0.5

so

A=0.5h(a+b)

0.5h is being multiplied with (a+b), taking this expression of left hand side gives

A/0.5(a+b)=h

OR

h=A/0.5(a+b)

This is the final answer

8 0
3 years ago
Create the tables and appropriate constraints based on the following ER diagram. Use appropriate data types. Note that the size
SpyIntel [72]

Answer:

See explaination

Explanation:

CREATE TABLE CATEGORY

(

cid int NOT NULL,

description varchar2(1000),

PRIMARY KEY (cid)

);

CREATE TABLE PRODUCT

(

pid int NOT NULL,

description varchar2(1000),

cid int,

price int,

p_size varchar2(1),

CONSTRAINT chk_price CHECK (price>0),

CONSTRAINT chk_size CHECK (p_size in ('S','M','L')),

CONSTRAINT fk_cid FOREIGN KEY (cid) REFERENCES CATEGORY(cid)

);

7 0
3 years ago
An example of live footage is when?
Zigmanuir [339]
A example of live footage is on camera, tv, or a live show happening at that moment 
6 0
3 years ago
Read 2 more answers
Andrea needs to format the legend on her chart. She clicks on the chart to select it. Which of the
Sever21 [200]
For Andrea to format the legend on her chart, she needs to click on the chart to select it. The Chart Tools option appears when a chart is selected. Andrea can build charts easily and successfully using the Chart Tool in Microsoft Excel or any other Spreadsheet programme. Let us assume that Andrea is using Microsoft Excel to create her chart. When she opens Excel and looks at the ribbon band on top of the new spreadsheet, there is an option to create charts. Using this option, she can create as many charts as she needs to 
7 0
3 years ago
Other questions:
  • Artists who draw images on a computer often use a stylus in conjunction with special _________ tablets, which offer extra-sensit
    15·1 answer
  • What video game has made the most money as of 2016?
    15·2 answers
  • The word __________ refers to the numbers, words, or more generally, any collection of symbols that is manipulated by a program.
    7·1 answer
  • Which of the following is an example of an output device
    13·1 answer
  • Write a program to read from std_info.txt.
    11·1 answer
  • Write a paragraph explaining why you think its important to use ethics in computers
    9·1 answer
  • HELP MY TABLET KEEPS ON REBOOTING I TRIED TO FACTORY RESET BUT IT KEEPS ON REBOOTING
    12·2 answers
  • QUESTION 4
    13·1 answer
  • I WILL MARK BRAINIEST FOR THIS!!!!!!
    11·2 answers
  • What instructions would a computer have the hardest time completing correctly
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!