def print_results(score, num_questions, total_time): """Calculates and displays the final grade and feedback.""" percentage = round((score / num_questions) * 100, 1) print("\n" + "=" * 40) print(" QUIZ RESULTS ") print("=" * 40) print(f"Final Score : {score} out of {num_questions}") print(f"Accuracy : {percentage}%") print(f"Time Taken : {total_time} seconds") if percentage == 100: print("Feedback : Perfect score! Outstanding job! 🎉") elif percentage >= 80: print("Feedback : Great work! You know your tables well. 👍") elif percentage >= 50: print("Feedback : Good attempt! Keep practicing. 💪") else: print("Feedback : Don't give up! Practice makes perfect. 📚") def start_quiz(): """Runs the multiplication quiz loop.""" print("=" * 40) print(" Welcome to the Multiplication Quiz!") print("=" * 40) min_val, max_val = select_difficulty() num_questions = get_positive_integer("\nHow many questions would you like? ") score = 0 start_time = time.time() for i in range(1, num_questions + 1): num1 = random.randint(min_val, max_val) num2 = random.randint(min_val, max_val) correct_answer = num1 * num2 print(f"\nQuestion {i}/{num_questions}: What is {num1} × {num2}?") user_answer = get_user_answer("Your answer: ") if user_answer == correct_answer: print("✨ Correct!") score += 1 else: print(f"❌ Incorrect. The correct answer was {correct_answer}.") total_time = round(time.time() - start_time, 1) print_results(score, num_questions, total_time)