Page 460 - Computer Science V2.0 Class 11
P. 460
category = input("Enter the category for the question: ")
question = input("Enter the question: ")
options = []
for i in range(4):
options.append(input("Enter option {}: ".format(i + 1)))
correctAnswer = input("Enter the correct answer (1-4): ")
if category not in quizData:
quizData[category] = []
quizData[category].append({
'question': question,
'options': options,
'correctAnswer': int(correctAnswer)
})
def modifyQuestion(quizData):
category = input("Enter the category of the question to modify: ")
if category in quizData:
questionIndex = int(input("Enter the index of the question to modify (1-{}):
".format(len(quizData[category])))) - 1
if 0 <= questionIndex < len(quizData[category]):
question = quizData[category][questionIndex]
print("Current Question: {}".format(question['question']))
newQuestion = input("Enter the modified question: ")
question['question'] = newQuestion
print("Question modified successfully.")
else:
print("Invalid question index.")
else:
print("Category not found.")
def deleteQuestion(quizData):
category = input("Enter the category of the question to delete: ")
if category in quizData:
questionIndex = int(input("Enter the index of the question to delete (1-{}):
".format(len(quizData[category])))) - 1
if 0 <= questionIndex < len(quizData[category]):
del quizData[category][questionIndex]
print("Question deleted successfully.")
else:
print("Invalid question index.")
else:
print("Category not found.")
def registerStudent():
studentName = input("Enter your name: ")
return studentName
def selectCategory(quizData):
print("Available Categories: {}".format(", ".join(quizData.keys())))
446 Touchpad Computer Science (Ver. 2.0)-XI

