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]
2 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]2 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
2. The password dilemma refers to the fact that: A. Passwords that are easy for users to remember are also easy for attackers to
Sholpan [36]

Answer:

Option A.

Explanation:

5 0
2 years ago
Write structured pseudocode to show the following: when you are on time for work you have time to buy coffee
faltersainse [42]

Answer:

If( on_time == True) {

     print("Coffee")

} else {

    print("No Coffee")

}

Explanation:

Step 1 evaluate with a boolean variable if you are on time

If( on_time == True) {

Step 2 if true you have coffee

print("Coffee")

Step 3 if false you have not coffee

print("No Coffee")

3 0
3 years ago
Mr. Hill has 27 students in his class and Mr. Chang has 24 students in his class. Both classes will be divided into equal sized
iVinArrow [24]
25! 27+24=51 if you divide 51 by two, you get 25.5
Because we can’t have a 0.5th of a child, you can round down to the nearest whole number. Leaving you with 25. Hope this helped :)

(modulus division works well for these kinds of questions)
6 0
3 years ago
What are the 8 tips for<br>healthy living?​
disa [49]

Answer:

Base your meals on starchy foods.

Eat lots of fruit and vegetables.

Eat more fish.

Cut down on saturated fat and sugar.

Try to eat less salt- no more than 6g a day.

Get active and try to be a healthy weight.

Drink plenty of water

Explanation:

7 0
3 years ago
Read 2 more answers
Suppose you are a merchant and you decide to use a biometric fingerprint device to authenticate people who make credit card purc
luda_lava [24]

Answer:

i dont know the answer

Explanation:

3 0
2 years ago
Other questions:
  • How to remove a channel from favorite list on suddenlink?
    15·1 answer
  • Which of these is a social consequence of effective communication
    12·1 answer
  • To steal credit card information by installing devices on card readers located in ATMs, gas pumps, restaurants, grocery stores,
    13·2 answers
  • A software development company wants to reorganize its office so that managers and the Computer Programmers they supervise can b
    13·2 answers
  • 1. Briefly explain the concept of signature of a function, in a function declaration. What signature components are crucial for
    9·1 answer
  • Write the method addItemToStock to add an item into the grocery stock array. The method will: • Insert the item with itemName ad
    12·1 answer
  • Explain two ways by which the calendar meets or fails to meet the criteria of showing the correct data
    7·1 answer
  • 8.18 **zyLab: Schedule Generator Write this program using an IDE. Comment and style the code according to the CS 200 Style Guide
    13·1 answer
  • What does CPU stand for
    7·1 answer
  • Which of the following is not a component of Power BI?
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!