# main.py from settings import WELCOME, GOOD_LUCK from instructions import show_instructions from questions import ask_question from score import ScoreTracker def get_number_of_questions(): while True: try: amount = int(input("How many questions would you like to do? ")) if amount > 0: return amount print("Please enter a number greater than 0.") except ValueError: print("Please enter a whole number.") def show_results(score): print("\n========== RESULTS ==========") print(f"Questions Answered : {score.total()}") print(f"Correct Answers : {score.correct}") print(f"Incorrect Answers : {score.incorrect}") print(f"Score Percentage : {score.percentage():.1f}%") if score.percentage() == 100: print("Excellent work!") elif score.percentage() >= 80: print("Great job!") elif score.percentage() >= 60: print("Good effort!") else: print("Keep practicing!") print("=============================") def main(): print(WELCOME) print(GOOD_LUCK) # Show the instructions show_instructions() # Ask how many questions the user wants number_of_questions = get_number_of_questions() # Create a score tracker score = ScoreTracker() # Ask the questions for question in range(1, number_of_questions + 1): if ask_question(question): score.add_correct() else: score.add_incorrect() # Display the final results show_results(score) if __name__ == "__main__": main()