Python for beginners
Svector94 opened this issue · comments
PHILOSOPHY AND LOGIC Quiz,
Input your name and start quiz___hsllo
hsllo
Q1: what is the capital of Edo?__
Source code:
#A simple CBT quiz using phython
print (" PHILOSOPHY AND LOGIC Quiz,")
name=str(input("Input your name and start quiz___"))
print(name)
questions = [
{
"question": "what is the capital of Edo?__",
"answer": "Benin"
},
{
"question": "Which planet is known as the Red Planet?",
"answer": "Mars"
},
{"question": "Philosophy could be defined as __________?",
"answer": "Love of wisdom/knowledge by Plato"
},
{"question": "How old is Nigeria",
"answer": "63"
},
{"question": "what kind of language is python ",
"answer": "High level language"
},
{"question": "Epistemology or the ________ of knowledge is the branch of philosophy which is concerned with the nature and scope of knowledge",
"answer": "Theory"
},
{"question": "what is the full meaning of FUTA",
"answer": "federal university of technology Akure"
}
]
score = 0
current_question = 0
while current_question < len(questions):
question_data = questions[current_question]
question = question_data["question"]
correct_answer = question_data["answer"]
# Present the question to the user and get their answer
user_answer = input(f"Q{current_question + 1}: {question} ")
# Check if the user's answer is correct
if user_answer.lower() == correct_answer.lower():
print("Correct!\n")
score += 1
else:
print(f"Wrong! The correct answer is: {correct_answer}\n")
# Move to the next question
current_question += 1
print(f"Your score is: {score}/{len(questions)}")
def run_quiz():
questions = [
{
"question": "What is the capital of France?",
"answer": "Paris"
},
{
"question": "Which planet is known as the Red Planet?",
"answer": "Mars"
},
{"question": "Philosophy could be defined as __________?",
"answer": "Love of wisdom/knowledge by Plato"
},
{"question": "How old is Nigeria",
"answer": "63"
}
# Add more questions and answers here
]
score = 0
current_question = 0
while current_question < len(questions):
question_data = questions[current_question]
question = question_data["question"]
correct_answer = question_data["answer"]
# Present the question to the user and get their answer
user_answer = input(f"Q{current_question + 1}: {question} ")
# Check if the user's answer is correct
if user_answer.lower() == correct_answer.lower():
print("Correct!\n")
score += 1
else:
print(f"Wrong! The correct answer is: {correct_answer}\n")
# Move to the next question
current_question += 1
print(f"Your score is: {score}/{len(questions)}", "marks")
print ("CONGRATULATIONS")
run_quiz()