Lab Practice

  • Problem 1 :
    Write a function month_pay that has three parameters: total amount of the loan taken in the bank, the down payment, and the loan tearm (the number of YEARS the loan is taken for). The function returns the monthly payment - the amount user would need to pay every month to return the loan. For example, loan: $1200, down payment: $200, term: 1 year (pay attention it is 12 month!) then the monthly payment is $83.33 ((1200-200)/12)

    Write a function process, that has three parameters: list of loans, list of corresponding downpayments and the list of corresponding loan tearms. The function returns a new list - list of monthly payments. Use function month_pay to calculate monthly payment for each loan.

    Write main that reads a number of loans taken in the bank on specific day. The program then randomly generates three lists of integers: list of loans, list of downpayments and list of terms (use function make_list we wrote in the past). The program then uses function process to find monthly payments for each loan and finds the number of loans with monthly payments above $1000.

    Make a test input/output to test your program.

  • Problem 2 :
    Write a function replace_sum that has one parameter - list of integers. The function creates a new list using the following rule: each number is replaced by the sum of two numbers, one from the left and one from the right. For the first element the number from the left is the last element of the list. For the last element the number from the right is the first element. Function returns the new list.

    Example: in the example below I wrote how the sum was obtained, but in your program you only need to store the final result for the sum.

    old_list=[3, 4, 1, -2, 6, 7, 10, -3]

    new_list=[-3+4, 3+1, 4+(-2), 1+6, -2+7, 6+10, 7+(-3), 10+3]=[1, 4, 2, 7, 5, 16, 4, 13]