Hey there! Sign in to join this conversationNew here? Join for free
    • Thread Starter
    Offline

    2
    ReputationRep:
    import random#all the questions will be completely random
    score = 0#program will calculate their scores(starts with 0)
    ops = ['+','-','*']#list of the possible operations the random generator can choose to use for the 10 questions


    print("************************* ******************************** ******************************** *************WELCOME TO THE ARITHMETIC QUIZ!!************************** ")
    print(" ")#for presentation purposes
    print(" ")
    name=input(" Enter your name:")#python will store the user's name into a variable
    print(" Welcome to the Arithmetic Quiz",name,"! Good luck!")#


    this part is wrong:

    usersclass=int(input("Enter your class:5B,5G or 5R"))
    '5B'==class1
    '5G'==class2
    '5R'==class3

    if usersclass==class1:
    open("class5B.txt","a+")
    if usersclass==class2:
    open("class5G.txt","a+")
    if usersclass==class3:
    open("class5R.txt","a+")

    the rest works, apart from the small section above





    for i in range(10)this allows the questions to be asked for a total of 10 times
    FirstNumber = random.randint(1,15)#all the random numbers generated will range from the numbers 1 to 15
    SecondNumber = random.randint(1,15)
    operation = random.choice(ops)#random operations will be generated for each question
    print(" ")
    print(" What does",FirstNumber,operation, SecondNumber,"equal to?")
    user = int(input(" Enter your answer:"))#user can give their response to the question



    if operation == "+":
    answer = FirstNumber + SecondNumber#if the operation is addition, the program will work out the answer taking in this information
    elif operation == "-":
    answer = FirstNumber - SecondNumber
    elif operation == "*":
    answer = FirstNumber *SecondNumber



    if user == answer:
    print(" That is the correct answer! Keep it up.")#gives the user a message when correct
    score = score + 1#with each correct answer, a score is added
    else:
    print(" That is incorrect. The correct answer is",answer)#gives the user a message when incorrect


    print(" ")
    print(" Your total score is:",score,"/10")#displays their total score


    myfile=open('arithmetic_quiz_res ults.txt','w')
    class1=input("Enter class: ")
    myfile.write("Class:" +class1+"\n")
    for x in range (1):
    name=input("Student's name: \n")
    result=input("Score: ")
    myfile.write(name +'-'+result)
    myfile.close()


    That's my coding and If anyone else takes computer science can you please help me? I'm way past my deadline and would like some advice or help with how to do the coding. Thank you
    • Political Ambassador
    • Welcome Squad
    Offline

    16
    ReputationRep:
    Political Ambassador
    Welcome Squad
    (Original post by aliyahh16)
    import random#all the questions will be completely random
    score = 0#program will calculate their scores(starts with 0)
    ops = ['+','-','*']#list of the possible operations the random generator can choose to use for the 10 questions


    print("************************* ******************************** ******************************** *************WELCOME TO THE ARITHMETIC QUIZ!!************************** "
    print(" "#for presentation purposes
    print(" "
    name=input(" Enter your name:"#python will store the user's name into a variable
    print(" Welcome to the Arithmetic Quiz",name,"! Good luck!"#


    this part is wrong:

    usersclass=int(input("Enter your class:5B,5G or 5R")
    '5B'==class1
    '5G'==class2
    '5R'==class3

    if usersclass==class1:
    open("class5B.txt","a+"
    if usersclass==class2:
    open("class5G.txt","a+"
    if usersclass==class3:
    open("class5R.txt","a+"

    the rest works, apart from the small section above





    for i in range(10)this allows the questions to be asked for a total of 10 times
    FirstNumber = random.randint(1,15)#all the random numbers generated will range from the numbers 1 to 15
    SecondNumber = random.randint(1,15)
    operation = random.choice(ops)#random operations will be generated for each question
    print(" "
    print(" What does",FirstNumber,operation, SecondNumber,"equal to?"
    user = int(input(" Enter your answer:")#user can give their response to the question



    if operation == "+":
    answer = FirstNumber + SecondNumber#if the operation is addition, the program will work out the answer taking in this information
    elif operation == "-":
    answer = FirstNumber - SecondNumber
    elif operation == "*":
    answer = FirstNumber *SecondNumber



    if user == answer:
    print(" That is the correct answer! Keep it up."#gives the user a message when correct
    score = score + 1#with each correct answer, a score is added
    else:
    print(" That is incorrect. The correct answer is",answer)#gives the user a message when incorrect


    print(" "
    print(" Your total score is:",score,"/10"#displays their total score


    myfile=open('arithmetic_quiz_res ults.txt','w'
    class1=input("Enter class: "
    myfile.write("Class:" +class1+"\n"
    for x in range (1):
    name=input("Student's name: \n"
    result=input("Score: "
    myfile.write(name +'-'+result)
    myfile.close()


    That's my coding and If anyone else takes computer science can you please help me? I'm way past my deadline and would like some advice or help with how to do the coding. Thank you
    Is this the quiz one? Where you have to make a quiz? My code is much shorter I think
    • Thread Starter
    Offline

    2
    ReputationRep:
    (Original post by zXcodeXz)
    Is this the quiz one? Where you have to make a quiz? My code is much shorter I think
    yepp, that's the one
    maybe mines extra long bc I print out blank spaces for presentational purposes and stuff

    What did you for task 2?
    i'm trying different things but I don't know how to create 3 different files for the 3 classes so that when the student enters their class, their results are inputted into that particular file
    • Political Ambassador
    • Welcome Squad
    Offline

    16
    ReputationRep:
    Political Ambassador
    Welcome Squad
    (Original post by aliyahh16)
    yepp, that's the one
    maybe mines extra long bc I print out blank spaces for presentational purposes and stuff

    What did you for task 2?
    i'm trying different things but I don't know how to create 3 different files for the 3 classes so that when the student enters their class, their results are inputted into that particular file
    I'll check online what I wrote and I'll get back to you, by the way have you got the code for task 3?
 
 
 
  • See more of what you like on The Student Room

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

  • Poll
    Would you like to hibernate through the winter months?
    Useful resources

    Study tools

    Rosette

    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.

    Creating

    Make study resources

    Create all the resources you need to get the grades.

    Planner

    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.

    Papers

    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
  • See more of what you like on The Student Room

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

  • 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

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