In: Computer Science
create a program using IDLE where you will gather input from the user using a loop. The user needs to provide you with a list of test scores for two categories (two different classrooms). Test scores must be integer values between 0 and 10. You need to process each score so that you can output the following:
Number of test scores entered for classroom A.
Number of test scores entered for classroom B.
Average of test scores entered for classroom A.
Average of test scores entered for classroom B.
EX:
Classroom A (a), Classroom B(b) or Quit (q): a
room A score: 10
Classroom A (a), Classroom B(b) or Quit (q): b
room B score: 8
Classroom A (a), Classroom B(b) or Quit (q): a
room A score: 8
Classroom A (a), Classroom B(b) or Quit (q): q
You entered 2 score(s) for room A with an average of 9.0
You entered 1 score(s) for room B with an average of 8.0
i = True
s1 = 0
s2 = 0
a = []
b = []
while (i == True): #iterate till input = q
print("Classroom A (a), Classroom B(b) or Quit (q):")
n = input()
if(n == 'a'):
a.append(int(input())) # classroom a values entered into list a
if(n == 'b'):
b.append(int(input())) # classroom a values entered into list b
if(n == 'q'):
for j in a:
s1 = s1 + j #calculating sum in class A
for k in b:
s2 = s2 + k #calculating sum in class b
print("You entered", len(a)," score(s) for room A with an average of ",(float(s1)/len(a))) #calualting average and output the result
print("You entered", len(b)," score(s) for room A with an average of ",(float(s2)/len(b))) #calualting average and output the result
i = False