Hey! Sign in to get help with your study questionsNew here? Join for free to post

A453 OCR Computing Controlled Assessment Task 3 Help?

Announcements Posted on
Last day to win £100 of Amazon vouchers - don't miss out! Take our quick survey to enter 24-10-2016
    • Thread Starter

    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(["+", "-", "*"])
    print("Please solve:\n", num1, symbol, num2)
    user = int(input(""))

    if symbol == "+":
    answer = num1 + num2
    elif symbol == "-":
    answer = num1 - num2
    elif symbol == "*":
    answer = num1 * num2

    if user == answer:
    score = score + 1

    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='')
Write a reply…


Submit reply


Thanks for posting! You just need to create an account in order to submit the post
  1. this can't be left blank
    that username has been taken, please choose another Forgotten your password?
  2. this can't be left blank
    this email is already registered. Forgotten your password?
  3. this can't be left blank

    6 characters or longer with both numbers and letters is safer

  4. this can't be left empty
    your full birthday is required
  1. Oops, you need to agree to our Ts&Cs to register
  2. Slide to join now Processing…

Updated: May 1, 2016
TSR Support Team

We have a brilliant team of more than 60 Support Team members looking after discussions on The Student Room, helping to make it a fun, safe and useful place to hang out.

Would you rather find
Useful resources

Study tools


Essay expert

Learn to write like a pro with our ultimate essay guide.

Thinking about uni already?

Thinking about uni already?

See where you can apply with our uni match tool

Student chat

Ask a question

Chat to other GCSE students and get your study questions answered.


Make study resources

Create all the resources you need to get the grades.


Create your own Study Plan

Organise all your homework and exams so you never miss another deadline.

Resources by subject

From flashcards to mind maps; there's everything you need for all of your GCSE subjects.


Find past papers

100s of GCSE past papers for all your subjects at your fingertips.

Help out other students

Can you help? Study help unanswered threads

Groups associated with this forum:

View associated groups

The Student Room, Get Revising and Marked by Teachers are trading names of The Student Room Group Ltd.

Register Number: 04666380 (England and Wales), VAT No. 806 8067 22 Registered Office: International House, Queens Road, Brighton, BN1 3XE

Reputation gems: You get these gems as you gain rep from other members for making good contributions and giving helpful advice.