# A453 OCR Computing Controlled Assessment Task 3 Help?

Watch
Announcements
#1
So for the previous tasks, I am asked to create a random arithmetic quiz for a primary school teacher. The primary school teacher has 3 separate classes and all the scores must be saved on three different txt files depending on the users class. Now I must sort out the scores in the file:
• In an alphabetical order with each student’s high score for the tests.
• By the highest score, highest to lowest.
• By the average score, highest to lowest.

So far, I can sort out the scores in alphabetical order but how do i sort the scores out from highest to lowest and by the average score. Plz help asap CA is due in on Tuesday and I need to try to get an A. Thanks in advance

This is my coding so far:
import random

score = 0
if __name__ == '__main__':
name = input("What is your name? ").title()
class_name = input("Which class do you wish to input results for? ")
print('{}, Welcome to the OCR Controlled Assessment Maths Test'.format(name))
for count in range(10):
num1 = random.randint(1, 10)
num2 = random.randint(1, 10)
symbol = random.choice(["+", "-", "*"])
user = int(input(""))

if symbol == "+":
elif symbol == "-":
elif symbol == "*":

print("Correct!")
score = score + 1
else:
print("Incorrect")

print(", You Got", score, "Out Of 10")
filename = class_name, + ".txt"
with open(filename, 'a+') as f:
f.write("{} : {}".format(name, score)

viewclass = input("To view previous scores, enter your class number and type whether you want the scores to be arranged either alphabetically, by average score or highest to lowest scores?")

if viewclass=='1 alphabetically':
with open('1.txt', 'r') as r:
for line in sorted(r):
print(line, end='')

elif viewclass=='2 alphabetically':
with open('2.txt', 'r') as r:
for line in sorted(r):
print(line, end='')

elif viewclass=='3 alphabetically':
with open('3.txt', 'r') as r:
for line in sorted(r):
print(line, end='')
0
X

new posts
Back
to top
Latest
My Feed

### Oops, nobody has postedin the last few hours.

Why not re-start the conversation?

see more

### See more of what you like onThe Student Room

You can personalise what you see on TSR. Tell us a little about yourself to get started.

### Poll

Join the discussion

#### How do you prefer to get careers advice?

I like to speak to my friends and family (18)
8.74%
I like to do my own research online using careers specific websites (125)
60.68%
I like speaking to the careers advisors at school, college or uni (30)
14.56%
I prefer to listen watch videos or listen to podcasts of people in my chosen career (29)
14.08%
Something else (let us know in the thread) (4)
1.94%