Write a unit test for a function that calculates compound interest
Write a Python unit test for a function named calculate_compound_interest that takes principal amount, annual interest rate, time in years, and number of times interest is compounded per year as input, and returns the calculated compound interest, using the unittest framework to verify the function's correctness with sample test cases, including test_calculate_compound_interest_valid_input, test_calculate_compound_interest_zero_principal, test_calculate_compound_interest_zero_interest_rate, and test_calculate_compound_interest_negative_input.
Created May 6, 2026
Related Prompts
Create a thoughtful code review comment for a junior engineer
textWrite a constructive and detailed code review comment for a junior engineer, including specific examples from the code, suggestions for improvement, and explanations of best practices, while also offering encouragement and resources for further learning and growth.