A453 Arithmetic Quiz Task 2

Watch
aliyahh16
Badges: 2
Rep:
? You'll earn badges for being active around the site. Rep gems come when your posts are rated by other community members.
#1
Report Thread starter 5 years ago
#1
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_results.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
0
reply
username2471155
Badges: 20
Rep:
? You'll earn badges for being active around the site. Rep gems come when your posts are rated by other community members.
#2
Report 5 years ago
#2
(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_results.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
0
reply
aliyahh16
Badges: 2
Rep:
? You'll earn badges for being active around the site. Rep gems come when your posts are rated by other community members.
#3
Report Thread starter 5 years ago
#3
(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
0
reply
username2471155
Badges: 20
Rep:
? You'll earn badges for being active around the site. Rep gems come when your posts are rated by other community members.
#4
Report 5 years ago
#4
(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?
0
reply
X

Quick Reply

Attached files
Write a reply...
Reply
new posts
Back
to top
Latest
My Feed

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.

Personalise

What is your favourite revision method?

Taking notes manually (53)
21.37%
Note taking apps (6)
2.42%
Flashcards (49)
19.76%
Revision guides (15)
6.05%
Past papers (117)
47.18%
Something else (let us know in the thread) (8)
3.23%

Watched Threads

View All