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
Consider the problem where you are given an array of n digits [d and a positive integer b, and you need to compute the value of
Fofino [41]

Answer:

The question is completely described and solved below:

3 0
3 years ago
Which feature of a router provides traffic flow and enhances network security?
Vika [28.1K]
The answer would be...<span>ACLs</span>
6 0
3 years ago
For an activity with more than one immediate predecessor activity, which of the following is used to compute its earliest finish
laila [671]

Answer:

The correct option is A

Explanation:

In project management, earliest finish time for activity A refers to the earliest start time for succeeding activities such as B and C to start.

Assume that activities A and B comes before C, the earliest finish time for C can be arrived at by computing the earliest start-finish (critical path) of the activity with the largest EF.

That is, if two activities (A and B) come before activity C, one can estimate how long it's going to take to complete activity C if ones knows how long activity B will take (being the activity with the largest earliest finish time).

Cheers!

7 0
3 years ago
You are the security administrator for a bank. The users are complaining about the network being slow. It is not a particularly
bulgar [2K]

Answer:Denial of service

Explanation:Denial of service is the type of attack that is caused to the computer attacks. These attacks basically cause the circumstances such as difficulty in accessing of the website or resource, accessing particular computer system , creation of the traffic in network, This attack occurrence stops or create difficulties for the legal person to access the network .

Therefore, there is the occurrence of the Denial of service(DoS) in the bank's computer network.

3 0
3 years ago
Interpret the poem 'the popular field'as a definse of natural conservation​
olga2289 [7]

Answer:

<em><u>Consider the poem “The Poplar Field” as a defense of nature conservation. This poem is a defense of nature conservation. The poet's message is that trees shouldn't be cut down recklessly. ... The poet also says that though we can plant trees, they don't grow as fast as the trees are being cut down in the present time.</u></em>

Explanation:

7 0
3 years ago
Other questions:
  • Do we have to use intersection?
    6·1 answer
  • Which statement describes a disadvantage of e-government?
    9·1 answer
  • A meeting of the quality team June is nervous about suggesting ideas because he is not sure he understands why they are qualifie
    6·2 answers
  • Different video files and ______ can cause compatibility issues to arise between computer systems.
    8·1 answer
  • Format character of Date function that display the day of the month in 2 digits with leading zeros such as 01 to 31
    11·1 answer
  • If an image has only 4 colors, how many bits are necessary to represent one pixel’s color? Describe a new custom encoding that u
    8·1 answer
  • Which Windows feature allows secure printing over the Internet?​
    11·1 answer
  • Which mechanical switches are the loudest and clickiest?
    15·1 answer
  • Discuss at least 1 Microsoft Windows security features that could protect data?
    5·1 answer
  • If String str = "Computer Science";, then what is the value of str.substring(10);? ​
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!