+ 4
Help regarding tweaks needed in my code to make a quiz, please!
I'd like to try and create my own quiz but struggling since trying to use what I had found on YouTube. Any advice please? I'm only a beginner. https://code.sololearn.com/cPLbngwpV387/?ref=app
15 Respostas
+ 3
Kerrin Tarr Could you share your code please
+ 3
Elizaveta Davidenko Without any reason why this type of emoji in this thread.
+ 2
😝
+ 2
and what not?
boo boo boo
+ 2
I'll know
+ 1
Problems with SoloLearn compiler is that it requires you to input everything before the codes are thrown back to server for compilation, thus eliminating interactivity which is an essential feature of any program; except for Web Code, which are compiled locally.
See the Simple MC Quiz demo series provided by everything.js
https://www.sololearn.com/post/131295/?ref=app
https://code.sololearn.com/WKKkpq0efxai/?ref=app
+ 1
Updated Code:
https://code.sololearn.com/clFcbbsprlIL/?ref=app
the format of input is provided in the below screenshot : https://ibb.co/JBvWytN
+ 1
Kerrin Tarr
Please move the code link from question title into the Description section. Links in question title or tags doesn't work.
+ 1
Kerrin Tarr
Sorry, I think you misunderstood me, perhaps I was not clear 😁
I meant to say please edit your original question (above, top most) to move the link from question title into the Description section (still in your original question).
This is so thread visitors will see and can access the code immediately as they open this thread.
+ 1
My bad, sorry 😁 I've edited it, thank you.
+ 1
Big Thanks for understanding Kerrin Tarr 👍
+ 1
Many thanks Sami Khan! Just worked out what you meant by the screenshot 😅
+ 1
Elizaveta Davidenko Here you can give only answer if you know.
0
class Question:
def__init__(self, prompt, answer):
self.prompt = prompt
self.answer = answer
question_prompts = [
"Which country's capital is Lisbon?\n(a) Spain\n(b) Portugal\n(c) Germany\n(d) Andorra\n\n",
"What is the square root of 121?\n(a) 7\n(b) 9\n(c) 11\n(d) 13",
"Who was the UK Prime Minister before Boris Johnson?\n(a) Gordon Brown\n(b) David Cameron\n(c) John Major\n(d) Theresa May"
]
questions = [
Question(question_prompts [0], "b"),
Question(question_prompts [1], "c"),
Question(question_prompts [2], "d")
]
def run_test(questions):
score = 0
for Question in questions:
answer = input(question.prompt)
if answer == question.answer:
score +=1
print("You Scored" + "str(score)" + "/" + str(len(questions)) + "Correct!")
run_test(questions)