Stuck on last part of project

homework
python_3

#1

Hi guys,

I am doing the OCR year 11 coursework in my free time to improve my coding skills (I’m in year 12 so I’m not cheating!).

I have done everything else apart from the last part, which states:

" a report that allows Fergus to choose a username, and outputs all of the quizzes that they have taken, and the grade for each of those quizzes.
b. a report that outputs for a selected topic and difficulty: the average score achieved, the highest score achieved, and the user details of the person that achieved the highest score"

I have no idea how to do the last parts.

I have stored the username, topic, difficulty and grade in the same file, the difficulty and topic in another file and the name, school year and password in another file

Here is the relevant parts of the code. Please can you guys help?

import csv
import random

print("Welcome to the quiz")

file = open("compques.csv","r")
file_reader = csv.reader (file)

complist = []
for row in file_reader:
    complist.append(row)



###################################

file1 = open("mathsques.csv","r")
file_reader1 = csv.reader (file1)

mathslist = []
for row in file_reader1:
    mathslist.append(row)




name = str(input("Enter your name"))
year = input("Enter your year group")
password = input(("Enter your password"))

def file():
    file = open("namepassword.txt", "a")
    file.write(name + year + password)

file()

if len(name) == 1:
    print("Your username is " + name[0]+ year)
elif len(name) == 2:
    print("Your username is " + name[0] + name[1] + year)
elif len(name) > 2:
    print("Your username is " + name[0] + name[1] + name[2] + year)






topic = input("What topic do you want to be tested on? Computer Science or Maths?")
print(" ")


if topic == "Computer science" or topic == "Computer Science" or topic == "computer science" or topic == "computer Science":
    print("You have selected computer science")

else:
    print("You have selected maths")




difficulty = input(str("What diffculty would you like? easy, medium or hard"))

questionrowszero = [0,0,0]  # in order
randomnumber = random.randint(0,2)
questionrowstwo = [2,2,2]
questionrowsfour = [4,4,4]
questionrowssix = [6,6,6]
questionrowseight = [8,8,8]

counter = 0
#0,2,4


print(" ")

print(counter)

print(" ")
if counter == 5:
    print("You scored 5 out of 5! You achieved 100% on your " + topic , difficulty + " quiz! You got a grade A!")
    grade = "A"
elif counter == 4:
    print("You scored 4 out of 5! You achieved 80% on your " + topic , difficulty + " quiz. You got a grade B!")
    grade = "B"
elif counter == 3:
    print("You scored 3 out of 5. You achieved 60% on your " + topic , difficulty + " quiz. You got a grade C")
    grade = "C"
elif counter == 2:
    print("You scored 2 out of 5. You achieved 40% on your " + topic , difficulty + " quiz. You got a grade D")
    grade = "D"
elif counter == 1:
    print("You scored 1 out of 5. You achieved 20% on your " + topic , difficulty + " quiz. You got a grade E")
    grade = "E"
elif counter == 0:
    print("You scored 0 out of 5. You achieved 0% on your " + topic , difficulty + " quiz. You got a grade F")
    grade = "F"





def file3():
    file3 = open("userchoices.txt", "a")
    file3.write(difficulty + topic)


file3()


def file4():
    file4 = open("outputuser.txt","a")
    file4.write(name + topic + difficulty + grade)


file4()

I have done the earlier parts of which I’m asking 5 questions based on topic and difficulty


#2

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.