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
Quick time and flash are two examples of what product
zheka24 [161]

there apps .........

8 0
3 years ago
1)Which of the following statements about the print statement are TRUE? (Check all that apply)
balu736 [363]

Answer:

1) C

5) D

6) A

Explanation:

3 0
3 years ago
An IT specialist is consulted about setting up a peer-to-peer network. What would the specialist say about security risk in this
ohaa [14]

I just did this, its A

6 0
3 years ago
Read 2 more answers
If a printer is not Wi-Fi capable, how can it be set up to provide the most reliable wireless printing
SCORPION-xisa [38]

Answer:

Well you can use bluetooth since it doesn’t require wifi and it would still work if your printing a file from your computer or your flash drive.

5 0
2 years ago
Read 2 more answers
Which of the following is not considered a flow in supply chains?
kramer
I don’t know if this helps, but here are three types of main flows: flow of material/goods, flow of money/cash, and flow of information.
5 0
2 years ago
Other questions:
  • Which extensions can help drive installs of your mobile app?
    12·1 answer
  • Can a computer will work more efficiently if you perform disk optimization
    9·1 answer
  • What are some programs that you have used that have condition-controlled loops and count-controlled loops?
    10·1 answer
  • Florida Highway Safety and Motor Vehicles reported blank of traffic fatalities were alcohol-related in Florida in 2009.​
    8·1 answer
  • Match each type of software license with the appropriate definition.
    11·1 answer
  • About how long did it take to photograph Daguerre's photograph of the street?
    7·1 answer
  • Next, Kim decides to include a diagram of a frog’s life cycle in her presentation. She wants to use an image that is part of a p
    15·2 answers
  • New trends, tools, and languages emerge in the field of web technology every day. Discuss the advantages of these trends, tools,
    15·1 answer
  • Discuss, in detail, the usefulness of graphics and images in program development. Explain the importance of the interface of a c
    7·1 answer
  • Which term refers to the use of the internet at work for personal use?.
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!