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
19. Fair use applies to which of the following situations?
MatroZZZ [7]
I think it’s B if not it’s D both are similar
4 0
3 years ago
WILL MARK BRAINLIEST.....
slamgirl [31]

Answer:

Variables. A variable is a way of naming and storing a value for later use by the program, ... its type, and optionally, setting an initial value (initializing the variable). ... byte x; x = 0; x = x - 1; // x now contains 255 - rolls over in neg. direction

Explanation:

7 0
3 years ago
What were second generation languages that required detailed knowledge of the computer's hardware and a lot of spare time to wri
Natalija [7]

Answer:

Assembly language is also known as second generation language. We can also say it low level language. To implement assembly language on hardware it require a lot of knowledge of computer hardware.

Mostly assembly language is used in Kernel and hardware drives like RAM or ROM these hardware parts belong to second generation. So, assembly language require a lot of knowledge of hardware as well spare time also to write it to get desired output from the hardware.

Assembly language is also used in video editing and video games and require a lot of time.

I hope it will help you!

4 0
3 years ago
Which expression correctly determines that String s1 comes before String s2 in lexicographical order
Assoli18 [71]

Options :

A.) s1 < s2

B.) s1 <= s2

C.) s1.compareTo(s2) == −1

D.) s2.compareTo(s1) < 0

E.) s1.compareTo(s2) < 0

Answer: E.) s1.compareTo(s2) < 0

Explanation: Lexicographical ordering simply means the arrangement of strings based on the how the alphabets or letters of the strings appear. It could also be explained as the dictionary ordering principle of words based on the arrangement of the alphabets. In making lexicographical comparison between strings, the compareTo () method may be employed using the format below.

If first string = s1 ; second string = s2

To compare s1 with s2, the format is ;

s1.compareTo(s2) ;

If s1 comes first, that is, before s2, the method returns a negative value, that is a value less than 0 '< 0', which is the case in the question above.

If s2 comes first, that is, before s1, the method returns a positive value, that is a value greater than 0 '> 0'.

If both are s1 and s2 are the same, the output will be 0.

8 0
3 years ago
.What is Social Media"?
nadezda [96]

Answer:

Social media is an internet-based form of communication. It facilitates the users the sharing of ideas, thoughts and information, and create web content.

There are many forms of social media, like blogs, photo-sharing sites, virtual words, etc.

8 0
3 years ago
Other questions:
  • Which process refers to starting up a computer?
    9·2 answers
  • 1. Which sign-in method requires users to press Ctrl+Alt+Delete before signing in?
    5·1 answer
  • What is a special class of adware that collects data about the user and transmits it over the Internet without the user’s knowle
    14·1 answer
  • Matthew is running a study on the effects of room temperature on performance on an algebra test. One group takes the test in a r
    5·1 answer
  • A user purchased a new smart home device with embedded software and connected the device to a home network. The user then regist
    5·1 answer
  • Help me please! (*18* points!)
    5·1 answer
  • Select three physical forms of storage. USB drive Primary cache Magnetic storage Secondary cache Dynamic RAM Optical drive
    7·2 answers
  • Which code will print a random number between 1 and 100?
    15·2 answers
  • 1. Create an optimized function "print s(n,s)" that prints the given argument s (representing a string) k times. k represents th
    7·1 answer
  • What type of natural disaster stuck haiti in 2010 and killed more than 200,000 people
    9·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!