Problem: Manually creating quizzes for assessments can be time-consuming and repetitive.
Solution: Automates the process of generating random quizzes from a question bank, allowing teachers to create tests quickly.
Benefits: Teachers can easily create quizzes for assessments, ensuring they cover various topics and difficulty levels.
Adoption: This can be extended by integrating with databases of question banks and adding options for different types of questions.
Code:
import random
# Question bank (for simplicity, using only a few questions)
question_bank = {
'What is 2 + 2?': ['4', '5', '3'],
'What is the capital of France?': ['Paris', 'Berlin', 'Rome'],
'What is 3 * 3?': ['9', '6', '8'],
}
# Function to generate random quiz
def generate_quiz():
questions = random.sample(list(question_bank.items()), 3) # Generate 3 random questions
print("Quiz:")
for question, options in questions:
random.shuffle(options)
print(f"Q: {question}")
for idx, option in enumerate(options, 1):
print(f"{idx}. {option}")
print()
# Generate a quiz
generate_quiz()
No comments:
Post a Comment