In: Computer Science
SAT Score Analysis
You have been asked to analyze SAT scores (which may be 400 - 1600).
You will be analyzing a population (a list) which consists of a number of
samples (lists) of student scores.
Here is the code to generate the population/samples:
import random
population=[]
for i in range(5):
sample = []
n = random.randint(5,10)
for num in range(n):
sample.append(random.randrange(400,1600))
population.append(sample)
The analysis should be conducted as follows:
##calculate the total number of scores
##calculate the total value of all scores
##find the average score of the population
##print the total number of scores
##print the total value of all scores
##print the average of all of the scores
##while a sample has an average that is less than the
##average of all scores add a random value 1000 - 1600
##to the sample until the average is no longer less than
##the average of all scores
##please note: this could result in lots of numbers
##being appended to the sample
##print the population
##adjust the population by
##removing the highest and lowest scores from each sample
##print the (adjusted) population
##calculate the total number of (adjusted) scores
##calculate the total value of all (adjusted) scores
##find the average score of the (adjusted) population
##print the total number of (adjusted) scores
##print the total value of all (adjusted) scores
##print the average of all of the (adjusted) scores
Done in Python Format please
import random
population=[]
for i in range(5):
sample = []
n = random.randint(5,10)
for num in range(n):
sample.append(random.randrange(400,1600))
population.append(sample)
total = score = 0;
for sample in population:
total+=len(sample)
score+=sum(sample)
avg = score/total
print("Sum of scores =",score)
print("Total no. of scores =",total)
print("Average score = ",avg)
print()
print("Population after average adjustment : ")
print()
for sample in population:
savg = sum(sample)/len(sample)
while(savg<avg):
sample.append(random.randint(1000,1600))
savg = sum(sample)/len(sample)
for sample in population:
temp = list(map(str,sample))
print(','.join(temp))
print()
print("Population after extremum adjustment : ")
print()
for sample in population:
mx = max(sample)
mn = min(sample)
sample.remove(mx)
sample.remove(mn)
temp = list(map(str,sample))
print(','.join(temp))
total = score = 0
for sample in population:
total+=len(sample)
score+=sum(sample)
avg = score/total
print()
print("Sum of adjusted scores =",score)
print("Total no. of adjusted scores =",total)
print("Average adjusted score = ",avg)