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
AP CSA help needed. Java please.
leva [86]
#include using namespace std;int main(){int year = 12,value = 10,total = 0;do{year++;value *= 2;total += value;}while(value*2 < 1000);cout << "Age: " << year << endl;cout << "Last gift: " << value << endl;cout << "Total: " << total << endl;cin.get();return 0;
5 0
2 years ago
A window may be resized by dragging the___ or side of it
dangina [55]

top i believe is the answer


4 0
3 years ago
Read 2 more answers
Larry recently viewed an auction listing on a website. as a result, his computer executed code that popped up a window that aske
RUDIKE [14]
<span>Larry recently viewed an auction listing on a website. as a result, his computer executed code that popped up a window that asked for his password. The type of attack larry had likely encountered is the </span><span>Cross-site scripting (XSS).</span>
4 0
3 years ago
¿la tecnología en Venezuela a nivel educativo, es ideal para desarrollar adecuadamente un proceso de Educación a distancia?
antiseptic1488 [7]

Answer:

There is no longer any doubt at this point that technology in education is absolutely necessary, because, thanks to technological advances in this area, we have more tools to offer more attractive and competent learning models. Teachers have more resources than whiteboards, chalks and books, while students learn by having fun, adapting to their digital environments. We will see below the new challenges that this entails in education and what are its benefits.

4 0
2 years ago
IPv4 address are of how many types?<br>​
Butoxors [25]

Answer: four different types

There are four different types of IPv4 addresses: public, private, static, and dynamic. While the public and private are indicative of the location of the network—private being used inside a network while the public is used outside of a network—static and dynamic indicate permanency.

7 0
3 years ago
Other questions:
  • When Clara accesses the programs and documents on her computer by way of icons, she is said to be employing
    15·1 answer
  • a) Write out an abstract class to represent a ball. Include data fields to store the weight of the ball as a double value and th
    6·2 answers
  • Which of these organs is not found in the excretory system
    7·2 answers
  • When a person bullies someone using technology, it's called:
    9·2 answers
  • Write a function:
    13·1 answer
  • One of the factors that influence the effectiveness of chemical sanitizer works effectively between 13° C and 49° C​
    10·1 answer
  • What is one difference between the Simple Gear Train with Same Size Gears and Simple Gear Train with Different Size Gears?
    12·1 answer
  • Jill is configuring the AutoArchive feature in Outlook 2016. What is the default setting in relation to when AutoArchive
    8·1 answer
  • Select the correct answer. Cerise is explaining computer viruses to her students. What is the best way for her to explain a comp
    9·1 answer
  • How can I master networking my home/business computer(s) - Tv's - iot devices and make the whole system as secure as possible?
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!