Problem: Conducting and grading exams manually can be a complex process.
Solution: Automates the exam process by generating random questions, conducting the exam, and grading the results.
Benefits: Provides faster feedback to students, reduces the administrative burden, and ensures fairness.
Adoption: This can be expanded to include different types of questions (e.g., essay questions, image-based questions).
Code:
import random
# Sample exam questions and answers
exam_questions = {
'What is 2 + 2?': '4',
'What is the capital of France?': 'Paris',
'What is 3 * 3?': '9',
}
# Function to conduct the exam
def conduct_exam():
score = 0
for question, answer in exam_questions.items():
user_answer = input(f"{question} ")
if user_answer == answer:
score += 1
print(f"Your score is {score} out of {len(exam_questions)}.")
# Run the exam
conduct_exam()
No comments:
Post a Comment