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
Paha777 [63]
3 years ago
10

Write a short program using Python that will:

Computers and Technology
1 answer:
Alexxx [7]3 years ago
6 0

Answer:

// program in Python to check perfect number

#function to find number is perfect or not

def is_Perfect_Number(n):

   #total variable

   tot = 1

   i = 2

   #sum of all divisor of number

   while i*i<=n:

       if n%i==0:

           tot = tot + i + n/i

       if tot == n and n != 1:

           return 1

       i = i+1  

   return 0

#read until user enter a perfect number

while True:

   #read integer

   num = int(input("Input an integer: "))

   #call the function

   if(is_Perfect_Number(num)):

       print(num,"is perfect number")

       #if perfect number break

       break

   else:

       print(num,"is not a perfect number")

       #ask again

   print("try again.")

Explanation:

Read number from user and then call the function is_Perfect_Number() with  parameter "num".This will find the sum of all divisor of number.If sum is  equal to number then it will return 1 else return 0.If the number is not  perfect then it will again ask to enter a number until user enter a perfect  number.

Output:

Input an integer: 24

24 is not a perfect number                                                                                                

try again.                                                                                                                

Input an integer: 28                                                                                                      

28 is perfect number

You might be interested in
Select the correct answer.
SpyIntel [72]

Answer:

i think real time fluid dynamics

Explanation:

3 0
3 years ago
By default the normal style inserts a vertical space equal to _____ lines between each line of text
nika2105 [10]
By default the normal style inserts a vertical space equal to 1.5 size vertical   lines between each line of text.
3 0
3 years ago
Which of the following is caused by wind erosion?
laila [671]
I'm not sure, but I think that  C : topsoil removal <span>is caused by wind erosion. I hope it helps</span>
7 0
3 years ago
Read 2 more answers
Create a class named Employee. The class must contain member variables for the employee name and salary. It should contain gette
Lerok [7]

Answer:

Explanation:

The following code was written in Java. The code contains the Employee class which contains the two variables (name, salary), the constructor, getter and setter methods for both variables, and an overwritten toString method. It also contains a tester class with the main method inside and creates a Employee object and initializes it. Then it calls the toString method. The output can be seen in the attached image below. Due to technical difficulties I have added the code as a txt file below.

8 0
3 years ago
How is primary storage different from secondary storage? Select the TWO correct statements.
Zina [86]
Primary storage refers to the main storage of the computer or main memory which is the random access memory or RAM. Secondary storage, on the other hand, refers to the external storage devices used to store data on a long-term basis.
7 0
3 years ago
Other questions:
  • Which of the following is NOT an example of input?
    8·1 answer
  • Store programming components in the shared folder. you want to secure the data in the folder as follows: members of the research
    11·1 answer
  • In this exercise, you are given a phrase and need to return that phrase in all capital letters.
    6·1 answer
  • Clearing the computer's cache helps store recently-used information.
    8·1 answer
  • Which of the selections below represents a recursive query?
    12·1 answer
  • Anyone know how to delete it in my laptop
    10·1 answer
  • The information given to you by your teachers is always accurate and should never be questioned. Please select the best answer f
    8·1 answer
  • *
    6·1 answer
  • Why it is not recommended to add sound effect on slide transition? Write at least two reasons.​
    6·1 answer
  • This is science I just couldn’t find it
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!