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
PtichkaEL [24]
3 years ago
8

Write a program in python that reads an unspecified number of integers from the user, determines how many positive and negative

values have been read, computes the total and average of the input values (not counting zeros). Your program ends with the input 0. Display the average as a floating-point with 2 digits after the decimal. Here is an example of sample run: Enter an integer, the input ends if it is 0: 1 Enter an integer, the input ends if it is 0: 2 Enter an integer, the input ends if it is 0: -1 Enter an integer, the input ends if it is 0: 3 Enter an integer, the input ends if it is 0: 0 The number of positivies is 3 The number of negatives is 1 The total is 5 The average is 1.25
Computers and Technology
1 answer:
blondinia [14]3 years ago
6 0

Answer:

count_p = 0

count_n = 0

total = 0

while True:

   number = int(input("Enter an integer, the input ends if it is 0: "))

   if number == 0:

       break

   else:

       total += number

       if number > 0:

           count_p += 1

       elif number < 0:

           count_n += 1

print("The number of positives is: " + str(count_p))

print("The number of negatives is: " + str(count_n))

print("The total is: " + str(total))

print("The average is: " + str(total / (count_p + count_n)))

Explanation:

Initialize the variables, count_p represens the number of positives, count_n represents the number of negatives, and total represents the total of the numbers

Create a while loop iterates until the user enters 0. If the number is not 0, then add it to the total. If the number is greater than 0, increase count_p by 1. If the number is smaller than 0, increase count_n by 1.

When the loop is done, print the count_p, count_n, total, and average

You might be interested in
You are supposed to do a report on something that interests you. You decided to do a report on dogs. As you research, you take n
Bas_tet [7]

Answer:

B

Explanation:

The sub topics should not be different than the main topic.

8 0
3 years ago
A navigation device that transfers packets of data between two or more networks is called a _______
Ira Lisetskai [31]
<span>A navigation device that transfers packets of data between two or more networks is called a Router.</span>
5 0
4 years ago
Here we have a program which is calling the subtract function to calculate the difference between two numbers. The value from th
statuscvo [17]

Answer:

See explanation

Explanation:

Given

The above program that subtracts two numbers and returns the result

Required

Modify the source code to run perfectly

When the given program is tested, it displays

<em>4 minus 10 equals -6 </em>

<em></em>

<em>Which is different from the expected output of</em>

<em>10 minus 4 equals 6 </em>

<em></em>

Modify

<em>solution = minuend-subtrahend </em>

<em>to</em>

<em>solution = subtrahend  - minuend</em>

<em></em>

And that does it.

8 0
3 years ago
What is the difference between requirements and controls in the security process? Give examples of each.
konstantin123 [22]

Answer:

Security controls are those measures taken to prevent, identify, counteract, and reduce security risks to computer systems, whereas, Security Requirements are guidelines or frameworks that stipulates measures to ensure security control.

Explanation:

Security controls encompass all the proactive measures taken to prevent a breach of the computer system by attackers. Security requirements are those security principles that need to be attained by a system before it can be certified as safe to use.

Security controls are of three types namely, management, operational, and technical controls. Examples of technical controls are firewalls and user authentication systems. A statement like 'The system shall apply load balancing', is a security requirement with an emphasis on availability.

4 0
3 years ago
How can a PowerPoint user add a shadow to a table
damaskus [11]
Https://wordribbon.tips.net/T010192_Drop_Shadows_for_Tables.html
8 0
3 years ago
Other questions:
  • What setting must be enabled to view data in Demographics and Interests Reports? Content Grouping Advertising features User perm
    13·1 answer
  • To view the results of a saved query, right-click the query in the Navigation Pane and click ____ on the shortcut menu.
    7·1 answer
  • When choosing a new computer to buy, you need to be aware of what operating _____ a0 it uses.
    6·1 answer
  • If needed, you can pull over on the shoulder of the freeway to take a break if you are tired. true or false (drivers ed) need as
    11·1 answer
  • If you can log into a website to add, edit, or delete content that has been added by you or another user, you are most likely us
    6·1 answer
  • A _____ defines what must take place, not how it will be accomplished.​
    12·1 answer
  • (a) [5 pts] Suppose you purchase a wireless router and connect it to your cable modem. Also suppose that your ISP dynamically as
    13·1 answer
  • How do you unblock sites on your computer
    14·2 answers
  • Low-level formatting ____. Group of answer choices is different from physical formatting is usually performed by the purchaser o
    11·1 answer
  • What is a thread? what resources does it share with other threads in the same process?
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!