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
REY [17]
4 years ago
10

(Analyze scores) Write a program that reads an unspecified number of scores and determines how many scores are above or equal to

the average and how many scores are below the average. Enter a negative number to signify the end of the input. Assume that the maximum number of scores is 100.
Here is a sample run:Enter a new score or negative number to exit: 99.1Enter a new score or negative number to exit: 85.6Enter a new score or negative number to exit: -1Total scores entered: 2Average score: 92.35Number of scores above or equal to the average: 1Number of scores below the average: 1

Computers and Technology
1 answer:
Angelina_Jolie [31]4 years ago
7 0

Answer:

#section 1

ls = []  

while True:

   score = float(input('Enter a New score or negative number to exit: '))

   if score < 0:

       break

   else:

       ls.append(score)

   

#section 2

average = sum(ls)/len(ls)

a = [num for num in ls if num >= average]

print('Total Scores Entered: ',len(ls))

print('Average score entered is: ',average)

print('Number of scores above average is: ',len(a))

print('Number of scores below average is:', len(ls)-len(a))

Explanation:

The programming language used is python 3.

#section 1

In this section, an empty list is initialized to hold all the values that will be inputted.

A while loop created which prompts the user to enter an input until a   negative value is entered. This while loop always evaluates to be true until a value less than 0 allows it to break.

Finally, all the scores are appended to the list.

#section 2

In this section the code gets the average by dividing the sum by the number of items in the list.

A new list 'a' is created to hold all the values that are greater than or equal to the average.

Finally, the results are printed to the screen.

I have attached an image with the example stated in your question.

You might be interested in
Assume inputFile is a Scanner object used to read data from a text file that contains a number of lines. Each line contains an a
anzhelika [568]

Answer:

words.hasNext()

Explanation:

Given the code snippet below:

  1.        while (inputFile.hasNextLine()) {
  2.            String word = "";
  3.            String line = inputFile.nextLine();
  4.            Scanner words = new Scanner(line);
  5.            while (words.hasNext()) {
  6.                word = words.next();
  7.            }
  8.            System.out.println(word); }
  9.    }

We have a inputFile Scanner object that can read data from a text file and we presume the inputFile has read several rows of data from the text file. So long as there is another line of input data available, the outer while loop will keep running. In each outer loop, one line of data will be read and assign to line variable (Line 3). Next, there is another Scanner object, words, which will take the current line of data as input. To get the last word of that line, we can use hasNext() method. This method will always return true if there is another tokens in its input. So the inner while loop will keep running so long as there is a token in current line of data and assign the current token to word variable. The word will hold the last token of current line of data upon exit from the inner loop. Then we can print the output (Line 8) which is the last word of the current line of data.

7 0
3 years ago
What is the keyboard shortcut used to paste previously copied text?
Sedbober [7]

Answer:

command or control + c

Explanation:

6 0
3 years ago
Read 2 more answers
2 What Java keyword is used to create a subclass? interface. extends. implements. inherits.
n200080 [17]

Answer:

extends

Explanation:

When you create a subclass, you basically say "I'm creating a new class, but for now it will look and behave the same as that other class", then you add its own personality.

The syntax is:

class SubClass extends SuperClass

Where SubClass is your new subclass what inherits methods and variables from the SuperClass.

So, if you add nothing to the SubClass, it will be a carbon copy of the SuperClass. But you can add methods and variables exclusive to this SubClass that the SuperClass won't have.

5 0
3 years ago
The best way to ensure the accuracy and safety of your accounts is to:
Gekata [30.6K]
Use symbols and a different password for each one

6 0
3 years ago
In the circuit seen here, the resistor has a resistance of 3 ohms. If no change in the battery size occurs, what will happen to
Rufina [12.5K]

It will increase by a factor of 2

6 0
3 years ago
Read 2 more answers
Other questions:
  • In a weighted scoring model, the sum of the weights of all the criteria must total _____ percent.
    15·1 answer
  • Christine would like to add something to her document that will illustrate the text. She should _____.
    10·2 answers
  • Two types of business communications enhanced by desktop publishing are
    7·2 answers
  • You administer a Microsoft SQL Server database that supports a banking transaction management application. You need to retrieve
    5·1 answer
  • When the print server processes documents waiting in the queue until the print device is available to accept the print job is ca
    14·1 answer
  • Identify whether each of the following goals would be a short-term or long-term goal for a high school senior who will graduate
    12·2 answers
  • With that ------ outlook he doesn't trust anyone.
    11·1 answer
  • Why would an information systems security practitioner want to see network traffic on both internal and external network traffic
    5·1 answer
  • Finish the program to compute how many gallons of paint are needed to cover the given square feet of walls. Assume 1 gallon can
    9·1 answer
  • What is the recipe for enchanting table?
    14·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!