Here’s an exercise for you programming enthusiasts like myself. Good Luck! ( : I wrote this while on toilet and I enjoy the look of this emoji, TMI?)
A small insurance company asks you to create a program to determine the cost of automobile insurance premium for each family member, based on their ages. The basic insurance price is 1000 per year per person.
Write a program that prompts the user for numbers of drivers in a family. Then use a repetition control structure to process each family member by asking for the name and age of each driver. Display the insurance amount for each family member. Use a method/function that takes the driver’s age as input and returns the insurance premium amount.
Calculation for premium amounts are:
| Ages 16 to 19 | Additional 15% of basic price
| Ages 20 to 25 | Additional 5% of basic price
| Age over 25 | Discount 10% of basic price
| Any other age | No insurance
Sample input and output could look like this:
Please enter the number of drivers in your family: 3
Driver 1 name: Wawa
Driver 1 age: 31
The amount of insurance for Wawa: $900.00
Driver 2 name: Phoenix750
Driver 2 age: 20
The amount of insurance for Phoenix750: $1050.00
Driver 3 name: Morgan Freeman
Driver 3 age: 16
The amount of insurance for Morgan Freeman: $1150.00
for i in range(int(raw_input("Please enter the number of drivers in your family: "))): print("The amount of insurance for "+raw_input("Driver "+str(i+1)+" name: ")+": $"+str(str([1150 if (16 <= age <= 19) else ( 1050 if (20 <= age <= 25) else ( 900 if age > 25 else 0)) for age in [int(raw_input("Driver "+str(i+1)+" age: "))]])).strip("[]"))