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
The procedure call mystery(38) will yield which output? __________ a) 0 12 b) 12 0 c) 1 1 0 2 d) 1 1 1 1 e) 2 0 1 1 public void
Ivan

Answer:

Option b is the correct answer for the above question.

Explanation:

  • The mystery function is a recursive function that calls for the two times when the user passes 38 on the argument.
  • The first value is 38 and the second value is 2 for which that function is called.
  • When the value 38 is passed, then again 2 is passed because of the "mystery (n % 3);" statement.
  • This statement holds by the if condition which gives the true when the argument value is greater than 2.
  • Hence for the 2 value the if condition will not true and the function is not called again.
  • Then the 38/3 and 2/3 are printed whose value is 12 0, but it will print 0 12 because of the recursive function.
  • Hence option b is the correct answer while the other is not because other options does not states the output of this program.
3 0
2 years ago
Operating systems are designed to work with specific hardware. Which operating system works with Apple computers?
Ghella [55]
2. Mac and to be more precisely, OS X
5 0
3 years ago
Read 2 more answers
Which type of operating system is usually used in personal computers?
castortr0y [4]
Windows 10 thru 7 home and some people use mac osx
7 0
3 years ago
Read 2 more answers
Write c program to check character is alphabate or not?​
Elan Coil [88]

Lookup the isalpha() function in the C standard library, this function will check and return non-zero for alphabetic characters.

8 0
3 years ago
When an entrepreneur has three employees at a busy and growing software company, what is the primary responsibility of the entre
polet [3.4K]

To direct the employees and respond to any calls/emails regarding a problem or upgrade that should be changed/fixed. (I don't know if that's what you wanted)

4 0
3 years ago
Read 2 more answers
Other questions:
  • What can a dimm use to hold data and amplify a signal just before the data is written to the module?
    12·1 answer
  • My home PC has IP address 192.168.1.22 and connects to the Internet through a NAT router. Assume I am downloading a web page fro
    5·1 answer
  • True or false?
    13·1 answer
  • The advent of optical discs was made possible by developments in ____ technology.
    5·1 answer
  • Word processing software, spreadsheet software, database software, and presentation software are examples of what category of co
    13·1 answer
  • Who is the prince of math?
    5·2 answers
  • Imagine you were going to use a dedicated workstation for an animation job rather than a personal PC or the all-purpose PCs you
    5·1 answer
  • What is a cpu in full explanation?
    7·2 answers
  • Tips for staying safe using social media. Using in your own words.
    6·1 answer
  • Post back maintains view state by assigning the form values to a hidden form field named ____.
    12·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!