adding a counter to a quiz [on hold]
i am not receiving any errors just the counter is not working it is remaining as a 0... i'm new to python. i'm planning to make a score board system later on and a timer if u could please help
from random import randint
path = ("/home/pi/Desktop/")
filename = ("CapitalCities.txt")
file = open(path + filename,"r")
counter = 0
incounter = 0
Lines = 0
for line in file:
Lines+=1
file.close()
file = open(path + filename,"r")
def wordcheck(cap,q_answer):
T = 0
for word in cap:
if word !=q_answer[T]:
print(word)
def generateQuiz():
incounter = 0
counter = 0
file = open(path + filename,"r")
randomquestion = randint(0,Lines)
count = 0
line = 0
for line in file:
count+=1
if(randomquestion == count):
question = line
sep = question.find("-")
cnt = question [:sep]
cap = question[sep+1:]
cap = cap.strip()
print ("Capital :"+ cap)
q_answer = input("what is the capital of "+ cnt +"?: ")
if q_answer != cap:
print(("Wrong! the answer is ")+ cap)
incounter += 1
return
else:
print("Well Done")
counter += 1
return
elif not line:
for i in range(3):
generateQuiz()
incounter_str = str(incounter)
counter_str = str(counter)
print(counter_str+" correct "+ incounter_str+ "incorrect")
python-3.x quiz
New contributor
put on hold as off-topic by AJNeufeld, Jamal♦ yesterday
This question appears to be off-topic. The users who voted to close gave this specific reason:
- "Code not implemented or not working as intended: Code Review is a community where programmers peer-review your working code to address issues such as security, maintainability, performance, and scalability. We require that the code be working correctly, to the best of the author's knowledge, before proceeding with a review." – AJNeufeld, Jamal
If this question can be reworded to fit the rules in the help center, please edit the question.
add a comment |
i am not receiving any errors just the counter is not working it is remaining as a 0... i'm new to python. i'm planning to make a score board system later on and a timer if u could please help
from random import randint
path = ("/home/pi/Desktop/")
filename = ("CapitalCities.txt")
file = open(path + filename,"r")
counter = 0
incounter = 0
Lines = 0
for line in file:
Lines+=1
file.close()
file = open(path + filename,"r")
def wordcheck(cap,q_answer):
T = 0
for word in cap:
if word !=q_answer[T]:
print(word)
def generateQuiz():
incounter = 0
counter = 0
file = open(path + filename,"r")
randomquestion = randint(0,Lines)
count = 0
line = 0
for line in file:
count+=1
if(randomquestion == count):
question = line
sep = question.find("-")
cnt = question [:sep]
cap = question[sep+1:]
cap = cap.strip()
print ("Capital :"+ cap)
q_answer = input("what is the capital of "+ cnt +"?: ")
if q_answer != cap:
print(("Wrong! the answer is ")+ cap)
incounter += 1
return
else:
print("Well Done")
counter += 1
return
elif not line:
for i in range(3):
generateQuiz()
incounter_str = str(incounter)
counter_str = str(counter)
print(counter_str+" correct "+ incounter_str+ "incorrect")
python-3.x quiz
New contributor
put on hold as off-topic by AJNeufeld, Jamal♦ yesterday
This question appears to be off-topic. The users who voted to close gave this specific reason:
- "Code not implemented or not working as intended: Code Review is a community where programmers peer-review your working code to address issues such as security, maintainability, performance, and scalability. We require that the code be working correctly, to the best of the author's knowledge, before proceeding with a review." – AJNeufeld, Jamal
If this question can be reworded to fit the rules in the help center, please edit the question.
add a comment |
i am not receiving any errors just the counter is not working it is remaining as a 0... i'm new to python. i'm planning to make a score board system later on and a timer if u could please help
from random import randint
path = ("/home/pi/Desktop/")
filename = ("CapitalCities.txt")
file = open(path + filename,"r")
counter = 0
incounter = 0
Lines = 0
for line in file:
Lines+=1
file.close()
file = open(path + filename,"r")
def wordcheck(cap,q_answer):
T = 0
for word in cap:
if word !=q_answer[T]:
print(word)
def generateQuiz():
incounter = 0
counter = 0
file = open(path + filename,"r")
randomquestion = randint(0,Lines)
count = 0
line = 0
for line in file:
count+=1
if(randomquestion == count):
question = line
sep = question.find("-")
cnt = question [:sep]
cap = question[sep+1:]
cap = cap.strip()
print ("Capital :"+ cap)
q_answer = input("what is the capital of "+ cnt +"?: ")
if q_answer != cap:
print(("Wrong! the answer is ")+ cap)
incounter += 1
return
else:
print("Well Done")
counter += 1
return
elif not line:
for i in range(3):
generateQuiz()
incounter_str = str(incounter)
counter_str = str(counter)
print(counter_str+" correct "+ incounter_str+ "incorrect")
python-3.x quiz
New contributor
i am not receiving any errors just the counter is not working it is remaining as a 0... i'm new to python. i'm planning to make a score board system later on and a timer if u could please help
from random import randint
path = ("/home/pi/Desktop/")
filename = ("CapitalCities.txt")
file = open(path + filename,"r")
counter = 0
incounter = 0
Lines = 0
for line in file:
Lines+=1
file.close()
file = open(path + filename,"r")
def wordcheck(cap,q_answer):
T = 0
for word in cap:
if word !=q_answer[T]:
print(word)
def generateQuiz():
incounter = 0
counter = 0
file = open(path + filename,"r")
randomquestion = randint(0,Lines)
count = 0
line = 0
for line in file:
count+=1
if(randomquestion == count):
question = line
sep = question.find("-")
cnt = question [:sep]
cap = question[sep+1:]
cap = cap.strip()
print ("Capital :"+ cap)
q_answer = input("what is the capital of "+ cnt +"?: ")
if q_answer != cap:
print(("Wrong! the answer is ")+ cap)
incounter += 1
return
else:
print("Well Done")
counter += 1
return
elif not line:
for i in range(3):
generateQuiz()
incounter_str = str(incounter)
counter_str = str(counter)
print(counter_str+" correct "+ incounter_str+ "incorrect")
python-3.x quiz
python-3.x quiz
New contributor
New contributor
New contributor
asked yesterday
Louie bernard LaybatsLouie bernard Laybats
1
1
New contributor
New contributor
put on hold as off-topic by AJNeufeld, Jamal♦ yesterday
This question appears to be off-topic. The users who voted to close gave this specific reason:
- "Code not implemented or not working as intended: Code Review is a community where programmers peer-review your working code to address issues such as security, maintainability, performance, and scalability. We require that the code be working correctly, to the best of the author's knowledge, before proceeding with a review." – AJNeufeld, Jamal
If this question can be reworded to fit the rules in the help center, please edit the question.
put on hold as off-topic by AJNeufeld, Jamal♦ yesterday
This question appears to be off-topic. The users who voted to close gave this specific reason:
- "Code not implemented or not working as intended: Code Review is a community where programmers peer-review your working code to address issues such as security, maintainability, performance, and scalability. We require that the code be working correctly, to the best of the author's knowledge, before proceeding with a review." – AJNeufeld, Jamal
If this question can be reworded to fit the rules in the help center, please edit the question.
add a comment |
add a comment |
0
active
oldest
votes
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes