Maths quiz that read/writes CSV files
You surely can shorten it by also improving readability

For example:

if Class == "1":
    with open ("class1.csv" , "w", newline='') as file:
        writer = csv.writer(file)
        for row in ScoresList:
            writer.writerow(row)

if Class == "2":
    with open ("class2.csv" , "w", newline='') as file:
        writer = csv.writer(file)
        for row in ScoresList:
            writer.writerow(row)


if Class == "3":
    with open ("class3.csv" , "w", newline='') as file:
        writer = csv.writer(file)
        for row in ScoresList:
            writer.writerow(row) `  


Becomes:

if Class in ("1", "2", "3"):
    with open ("class{}.csv".format(Class) , "w", newline='') as file:
        writer = csv.writer(file)
        for row in ScoresList:
            writer.writerow(row) `  


And, as you do that twice, you can extract it into a function to further avoid duplication.



You can also extract common code out of conditional branches

        if answer==realanswer:
            print("That's the correct answer")
            correctquestions = correctquestions + 1
        else:
            print("Unlucky not the corret")


is repeated in all of the ifs so you can write it just once at the bottom.