68,411 views
36 votes
36 votes
Write a program that creates an an array large enough to hold 200 test scores between 55 and 99. Use a Random Number to populate the array.Then do the following:1) Sort scores in ascending order.2) List your scores in rows of ten(10) values.3) Calculate the Mean for the distribution.4) Calculate the Variance for the distribution.5) Calculate the Median for the distribution.

User Pravin Suthar
by
2.8k points

2 Answers

23 votes
23 votes

Final answer:

To analyze test scores, a program can be written to create an array, randomly populate it with values, and find statistical measures such as mean, variance, and median.

Step-by-step explanation:

Program to Analyze Test Scores

To write a program that creates an array for 200 test scores between 55 and 99, populates it with random numbers, and performs statistical analysis, you would follow these steps:

  1. Initialize an array to hold 200 scores.
  2. Populate the array with random numbers between 55 and 99 using a random number generator.
  3. Sort the scores in ascending order.
  4. Display the scores in rows of ten.
  5. Calculate the mean (average) of the scores.
  6. Calculate the variance of the scores.
  7. Calculate the median score.

Note: The variance provides a measure of how much scores vary around the mean, and the median is the middle value when all scores are listed in order.

User Paul Andrew
by
2.5k points
20 votes
20 votes

Answer:

Step-by-step explanation:

The following code is written in Python. It uses the numpy import to calculate all of the necessary values as requested in the question and the random import to generate random test scores. Once the array is populated using a for loop with random integers, the array is sorted and the Mean, Variance, and Median are calculated. Finally The sorted array is printed along with all the calculations. The program has been tested and the output can be seen below.

from random import randint

import numpy as np

test_scores = []

for x in range(200):

test_scores.append(randint(55, 99))

sorted_test_scores = sorted(test_scores)

count = 0

print("Scores in Rows of 10: ", end="\\")

for score in sorted_test_scores:

if count < 10:

print(str(score), end= " ")

count += 1

else:

print('\\' + str(score), end= " ")

count = 1

mean = np.mean(sorted_test_scores)

variance = np.var(sorted_test_scores, dtype = np.float64)

median = np.median(sorted_test_scores)

print("\\")

print("Mean: " + str(mean), end="\\")

print("Variance: " + str(variance), end="\\")

print("Median: " + str(median), end="\\")

Write a program that creates an an array large enough to hold 200 test scores between-example-1
User Kamal Soni
by
3.4k points