My First Quiz
My First Quiz
class Question:
def __init__(self, prompt, answer):
self.prompt = prompt
self.answer = answer
question_prompts = [
"Chose the correct definision for a Vector (c++)\n(a) A sequential container to store elements and NOT index based\n(b) A fixed-size sequential collection of elements of the same type and it is index based",
"Can you reverse a string in Java?\nyes/\nno",
"Is this working? \nyes/\nno",
"What is this letter? (y) \n(y)\n(p)",
]
questions = [
Question(question_prompts[0], "a"),
Question(question_prompts[1], "no"),
Question(question_prompts[2], "yes"),
Question(question_prompts[3], "y"),
]
def run_quiz(questions):
score = 0
for question in questions:
answer = input(question.prompt)
if answer == question.answer:
score += 1
print("you got", score, "out of", len(questions))
run_quiz(questions)
#_____/\\\\\\\\\_____/\\\\\\\\\\\\\__________/\\\\\\\\\_____/\\\\\\\\\\\____/\\\\\\\\\\\\\___
# ___/\\\\\\\\\\\\\__\/\\\/////////\\\_____/\\\////////____/\\\/////////\\\_\/\\\/////////\\\_
# __/\\\/////////\\\_\/\\\_______\/\\\___/\\\/____________\//\\\______\///__\/\\\_______\/\\\_
# _\/\\\_______\/\\\_\/\\\\\\\\\\\\\/___/\\\_______________\////\\\_________\/\\\\\\\\\\\\\/__
# _\/\\\\\\\\\\\\\\\_\/\\\/////////____\/\\\__________________\////\\\______\/\\\/////////____
# _\/\\\/////////\\\_\/\\\_____________\//\\\____________________\////\\\___\/\\\_____________
# _\/\\\_______\/\\\_\/\\\______________\///\\\___________/\\\______\//\\\__\/\\\_____________
# _\/\\\_______\/\\\_\/\\\________________\////\\\\\\\\\_\///\\\\\\\\\\\/___\/\\\_____________
# _\///________\///__\///____________________\/////////____\///////////_____\///______________