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
Rom4ik [11]
3 years ago
10

Write a program that receives a series of numbers from the user and allows the user to press the enter key to indicate that he o

r she is finished providing inputs. After the user presses the enter key, the program should print:
The sum of the numbers

The average of the numbers

An example of the program input and output is shown below:

Enter a number or press Enter to quit: 1
Enter a number or press Enter to quit: 2
Enter a number or press Enter to quit: 3
Enter a number or press Enter to quit:

The sum is 6.0
The average is 2.0
BASE CODE

theSum = 0.0
data = input("Enter a number: ")
while data != "":
number = float(data)
theSum += number
data = input("Enter the next number: ")
print("The sum is", theSum)
Computers and Technology
1 answer:
kogti [31]3 years ago
5 0

Answer:

theSum = 0.0#defined in the question.

count=0 #modified code and it is used to intialize the value to count.

data = input("Enter a number: ") #defined in the question.

while data != "": #defined in the question.

   number = float(data) #defined in the question.

   theSum += number #defined in the question.

   data = input("Enter the next number or press enter to quit ") #defined in the question "only some part is modified"

   count=count+1#modified code and it is used to count the input to print the average.

print("The sum is", theSum)#defined in the question.

print("The average is", theSum/count) #modified code and it is used to print the average value.

output:

  • If the user inputs as 1,4 then the sum is 5 and the average is 2.5.

Explanation:

  • The above code is written in the python language, in which some part of the code is taken from the question and some are added.
  • The question has a code that tells the sum, but that code is not print the average value of the user input value.
  • To find the average, some codes are added, in which one count variable which is initialized at the starting of the program and gets increased by 1, when the user gives the value.
  • Then that count divides the sum to print the average.
You might be interested in
Complete the sentence to identify disadvantages of top-down programming design. Choose all that apply. Top-down programming desi
pav-90 [236]

so is it all about codes and codes and codes and codes and codes lol

4 0
3 years ago
output device. Vrite very short answer of the following questions. What is computer hardware? Which dovico in lini nwhich device
kirill115 [55]

Computer hardware is the physical components that a computer system requires to function.

Have a gr8 day ahead ✌️

7 0
2 years ago
Can someone please help me in answering this!?! <br> The language is C++
Llana [10]

Here is a somewhat cryptic solution that works:

#include <algorithm>

#include <cstdlib>

using namespace std;

void q(char c, int count)

{

for (int i = 0; i < count; i++) {

 putchar(c);

}

}

void p(int b1, int plusses)

{

q(' ', b1);

q('+', plusses);

}

int main()

{

for (int i = -3; i <= 3; i++)

{

 int pl = min(6, (3 - abs(i)) * 2 + 1);

 p(6-pl, pl);

 i == 0 ? p(0, 6) : p(6, 0);

 p(0, pl);

 putchar('\n');

}

getchar();

}


5 0
3 years ago
To recover a deleted document, what would you choose in the Info window?
kiruha [24]
Retrive you can restart your computer press f8 it will takr you to a menu were you can choos recover lost files then go from there
6 0
3 years ago
________ software consists of operating systems, utilities, device drivers, and language translators.
Hunter-Best [27]

Answer:

"System"

Explanation:

<u>System</u> software consists of operating systems, utilities, device drivers, and language translators.

(not much explanation as it was a fill in the blank which explains itself haha)

Have a nice day!

    I hope this is what you are looking for, but if not - comment! I will edit and update my answer accordingly. (ノ^∇^)

- Heather

3 0
2 years ago
Other questions:
  • 13. You're expecting an important call from Mr. Suarez, a potential customer. While waiting for this call, your supervisor calls
    15·1 answer
  • What would be one duty of a network administrator
    12·1 answer
  • Which of these engine components forms a tight seal between the piston and the cylinder and is necessary for proper engine opera
    13·2 answers
  • ¿Es especial que mi cumpleaños sea el día de San Valentín?<br><br> si o no
    11·2 answers
  • "Simon Says" is a memory game where "Simon" outputs a sequence of 10 characters (R, G, B, Y) and the user must repeat the sequen
    5·2 answers
  • So can u please follow my new ig acc i just started it yesterday its called stunnerspamz
    5·2 answers
  • How does a security information and event management system (SIEM) in a SOC help the personnel fight against security threats
    13·1 answer
  • Which type of measurement would you use to determine the mass of sugar?
    12·1 answer
  • 6
    7·2 answers
  • Web résumés allow you to include extra graphics and images that you would not include in a traditional résumé. please select the
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!