Life Insurance Monthly/Yearly Premium Payment Calculation
# Life Insurance Calculator
def calculate_premium(age, coverage_amount):
"""
Calculates the annual premium for a life insurance policy.
Args:
age (int): Age
of the policyholder.
coverage_amount (float): Desired coverage amount.
Returns:
float: Annual
premium amount.
"""
# Define premium
rate based on age range
if age < 18 or
age > 65:
raise
ValueError("Age must be between 18 and 65 to calculate the premium.")
elif age >= 18
and age <= 25:
premium_rate =
0.03
elif age >= 26
and age <= 35:
premium_rate =
0.04
elif age >= 36
and age <= 45:
premium_rate =
0.06
elif age >= 46
and age <= 55:
premium_rate =
0.08
else:
premium_rate = 0.1
# Calculate
premium amount
premium = coverage_amount * premium_rate
return premium
# Example usage
policyholder_age = 30
# Age of the policyholder
desired_coverage = 500000 # Desired coverage amount
premium_amount = calculate_premium(policyholder_age,
desired_coverage)
print(f"The annual premium amount is:
{premium_amount}")
In this script, we define a function calculate_premium() that takes the age of the policyholder and the desired coverage amount as inputs and returns the annual premium amount for a life insurance policy. The function calculates the premium based on predefined premium rates for different age ranges. If the age provided is outside the valid range (18 to 65), a Value Error is raised.
In the example usage section, the script demonstrates how to use the function by passing sample values for the policyholder's age and desired coverage amount. It then prints the calculated annual premium amount.
You can modify the values in the example usage section to calculate premiums for different policyholders and desired coverage amounts.