![jilliand2242](/avatars/18265.jpg)
jilliand2242
16.12.2019 •
Computers and Technology
Count positive and negative number and compute the average. the program will have the user input an unspecified number of integers.
determine how many are positive and negative.
compute the total and average. use a while loop.
output as follows:
enter an integer, the input ends if it is 0: 1 2 -1 3 0
the number of positives: 3
the number of negatives: 1
the total is 5.0
the average is 1.25
Solved
Show answers
More tips
- D Dating, Love, Relationships Why Should the Man be Active and the Woman Passive during Foreplay?...
- F Food and Cooking How to Properly Collect Mushrooms? A Comprehensive Guide...
- C Computers and Internet 3D Glasses! What is this thing?...
- C Computers and Internet How to insert videos into LiveJournal?...
- C Computers and Internet How Much Does an iPhone Cost in America?...
- F Family and Home How to Choose the Best Diapers for Your Baby?...
- F Family and Home Parquet or laminate, which is better?...
- L Leisure and Entertainment How to Properly Wind Fishing Line onto a Reel?...
- L Leisure and Entertainment How to Make a Paper Boat in Simple Steps...
- T Travel and tourism Maldives Adventures: What is the Best Season to Visit the Luxurious Beaches?...
Answers on questions: Computers and Technology
- M Mathematics In the cafeteria, 80 juice boxes were put out for breakfast. After breakfast, there were 20 juice boxes left. What is the ratio of juice boxes drunk to total juice boxes put...
- E English 5. True of False: William s dad had to travel 4 miles to pay the trader for the gumballs William ate....
- E English Restate this phrase in 5 different ways people are more dangerous and sneaky than they may appear....
Ответ:
The solution code is written in Python 3
total = 0 count = 0 neg = 0 pos = 0 num = int(input("Enter an integer: ")) while(num != 0): total += num count += 1 if(num < 0): neg += 1 else: pos += 1 num = int(input("Enter an integer: ")) print("The number of positives: " + str(pos)) print("The number of negatives: " + str(neg)) print("The total is " + str(total)) print("The average is " + str(total/count))Explanation:
Firstly, we create four variables, total , count, neg and pos (Line 1- 4). This is to prepare the variable to hold the value of summation of input integer (total), total number of input number (count), total negatives (neg) and total positives (pos).
Next, we prompt user for the first integer (Line 6).
Create a sentinel while loop and set the condition so long as the current input number, num is not equal to zero. the program will just keep adding the current num to total (Line 9) and increment the count by one (Line 10).
if num smaller than zero, increment the neg by one (Line 13) else increment the pos by one (Line 15). This is to track the total number of positives and negatives.
Finally, we can display all the required output (Line 20 - 23) using the Python built-in function print() when user enter 0 to terminate the while loop. The output shall be as follows:
The number of positives: 3
The number of negatives: 1
The total is 5
The average is 1.25
Ответ:
See explanation for full answer
Explanation:
Here are the new citations:
1)Vadukul, A. (2017, May 14). Driftwood Haiku on the Bronx Riviera. The New York Times, p. 1.
To fix this citation in APA the first name should be the first initial, the date should be second typed in ,month dd in paranthesis. The title of the article is not in quotes and the name of the newspaper goes in italics
2) Silverstein, S. (2017). Where the Sidewalk Ends: Poems and Drawings. New York,NY: HarperCollins.
To fix this citation in APA the first name is full last name, first initial. The year the book is published is next in paranthesis followed by where the publishing company is located and then the state and city. The last part is the publishing companies name
3)Rilke, R. M., & Snell, R. (2004). Letters to a young poet (917507652 721002613 M. H. Norton, Trans.). Mineola, NY: Dover Publications.
To fix this citation in APA the authors full last name and initials go first followed by the year the book was published in paranthesis. The title of the book goes next and if you have it the ISBN with the translator. The publishing company city,state then the publication company name.
4) Emerson, R. W., & Porte, J. (2003). The Poet in Nature and Selected Essays. New York, NY: Penguin House.
To fix this citation in APA again the authors names have to be last name and first initial. The year the book was published follows. Then the title of the book in italics. Followed by the information for the publishing company (city,state,publishing company title)
Hope this helps you!