{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

Laboratory Walkthrough 3

# Laboratory Walkthrough 3 - Submissiondeadline...

This preview shows pages 1–3. Sign up to view the full content.

Intro2cs Ex3 – Retirement Submission deadline Thursday,07 Novembe r, 20:55 Objectives In this exercise you will practice the use of functions, loops and working with files. You will also become familiar with data structures such as lists and tuples. Ex4 Ex4 will be published during the next week, and its submission date is Nov 14th. Some of the issues in that exercise will be learned in the “tirgulim” of next week. Planning for the future One of the most debatable issues lately in Israel is the question of retirement accounts (Pension plans). As you embark on a career, retirement may seem very far away, but it is critical for each and every one of us. A big debate in the press is related to the question of how the retirement funds of our generation will look like. Assuming a larger life expectancy, our retirement money should provide for us for more years. We encourage you to read more and then compare information from different sources. Although retirement may seem a long way off for you, we are going to explore some simple ideas in pension plans. Along the way, we are going to explore the use of successive approximation methods, as well as the use of some simple data structures, such as lists. We will start with a simple model of saving for retirement. Let's assume that an employee earns a constant salary. Each year the employee saves some percentage of his salary into his retirement fund. Assume you are the worker and your starting yearly salary is represented by salary ; the percentage of your salary you put into a retirement fund is save ; and the annual growth percentage of the retirement fund is growth_rate. Then your retirement fund, represented by the list F, should increase as following: Retirement fund End of year 1 F[0] = salary * save*0.01 End of year 2 F[1] = F[0]*(1+growth_rate*0.01)+salary*save*0.01 End of year 3 F[2] = F[1]*(1+growth_rate*0.01)+salary*save*0.01

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
Assignment 1 Implement a function named constant_pension that receives four arguments: a salary, saving percentage (in percentage), an annual growth percentage for the investment account, and a number of work years. The function should return a list where each element in the list represents the value of the retirement fund in the end of a year, with the most recent year’s value at the end of the list. Complete the implementation of constant_pension(salary, save, growth_rate, years) Write the code in the appropriate place in ex3.py template (you can find the link below). Make sure you’ve implemented the function as demanded, testing for bad inputs. To test your function, compare it with the school solution.
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}