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
Which of the following is NOT an advantage of owning a car?
AnnyKZ [126]

Smaller down and monthly payments than leasing a car

Option A.

<u>Explanation:</u>

If you lease a car, then the amount of money that a person has to pay in the form of monthly payments and installments is less when compared to when a person owns a car.

When you own a car, the monthly payment made is more than the monthly payments compared to when the car has to be leased. This is the disadvantage of owning a car, that the payment is more to be made.

8 0
3 years ago
When you enforce restrictions, what must you do immediately?
sweet [91]
The answer is A create a password
4 0
3 years ago
Read 2 more answers
What type of measurement are each of the following
bixtya [17]

Answer:

unities

Explanation:

Every one may be counted in unities

3 0
3 years ago
A ______ workstation is a network terminal that supports a full-featured user interface, but limits the printing or copying of d
Sladkaya [172]

Answer: The answer is a diskless workstation.

3 0
3 years ago
Which of the following is NOT a career in the Information Support and Services pathway?
frosja888 [35]

Answer:

here yuuuurrrrr Vote for me nah jk

6 0
2 years ago
Other questions:
  • The time between requests to a web server is exponentially distributed with mean 0.5 seconds. NOTE: This is a multi-part questio
    8·2 answers
  • How do you spell kiss in Japanese
    13·2 answers
  • _____ documentation is designed to help programmers and systems analysts understand the application software and maintain it aft
    12·1 answer
  • What these large numbers in unemployment could mean long term for America?
    6·1 answer
  • A(n) ______ system is a set of programs that coordinates all the activities among computer or mobile device hardware. a. managem
    10·1 answer
  • The chief intellectual property officer (CIPO) is responsible for collecting, maintaining, and distributing the organization's k
    14·1 answer
  • Which of the following statements is true about biometrices as an authentication method
    6·1 answer
  • Question No. 5:
    7·1 answer
  • You are an IT administrator troubleshooting a Windows-based computer. After a while, you determine that you need to refresh the
    10·1 answer
  • Answer the following 8-mark question in your book.
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!