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
When you use the keyboard to scroll to a different position in the document, the ____ automatically moves when you press the des
FrozenT [24]

Answer:

Option C i.e., insertion point is the correct option.

Explanation:

if any user or person scrolls the following contents by using the keyboard from one position to another position in the document of the user then, the insertion point moves automatically without any implementation when the user presses any key they want. If the user clicks on the arrow keys then, it also works like that. So, that's why the following option is correct.

8 0
3 years ago
An integer is said to be a perfect number if the sum of its divisors, including 1 (but not the number itself), is equal to the n
kirill115 [55]
True

explanation: bc it is
8 0
3 years ago
Consider the code block below. What is the value of amount when this method is called twice, the first time using cookieJar(7) a
RUDIKE [14]

Answer:

C. 22

Explanation:

Given that the argument is being passed by value, there is no memory to consider.  So cookieJar(7) returns 7 and cookieJar(22) returns 22.

If the argument parameter was passed by reference or pointer, then perhaps the value from cookieJar(7) would be considered with cookieJar(22).

Note, this code block really isn't doing anything other than returning the value passed into it.  The "amount" variable is immediately set to 0, and then the value passed in is added to amount (which is 0), and returns.  The following code could replace this function:

public static int cookieJar(int addCookies){

return addCookies;

}

The above code will return an equivalent output to the given code.

Notice, the function is not dependent on any previous call, so the value for each is unique to the call itself, i.e., cookieJar(22) returns 22 and cookieJar(7) returns 7.

So, C. 22 would be correct.

3 0
3 years ago
"Bookings are to be stored in three separate
Zina [86]

Answer:

it is a complete routine of life without it we cannot do time management

Explanation:

mark me brainliest ❤

5 0
3 years ago
Of the measures of feasibility, questions such as "Does the proposed platform have sufficient capacity for future needs?" and "W
larisa [96]
Operational feasibility !!!!!!!
8 0
4 years ago
Other questions:
  • Which of the following would allow for more data to be stored on a CD?
    11·2 answers
  • Computer user support helps people with minor computer problems. <br><br> True or False
    12·1 answer
  • Why is redundancy of data undersirable?
    7·2 answers
  • Suppose we have a linearly separable dataset, and we divide the data into training and validation sets. Will a perceptron learne
    8·1 answer
  • 1. Multiple Choice(25 points) 1) 4’b1001 represents the following decimal number______________ a) 8 b) 9 c) 10 d) 11 2) The foll
    10·1 answer
  • What does a motherboard legacy BIOS do?
    11·1 answer
  • Full form of computer
    12·1 answer
  • What is a task that is not associated with loading existing data into a new ERP system.
    11·2 answers
  • Write a Java program that will be able to generate the sample table below.
    5·1 answer
  • 1. The running configuration is also known as the _____________ (Select Two) a. Startup config b. Working configuration c. Curre
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!