473,661 Members | 2,502 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Calculating Inflation, retirement and cost of living adjustmentsover 30 years

rbt
Is this mathematically correct?
def inflation():
start = int(str.strip(r aw_input("How much money do you need each
month at the start of retirement: ")))
inflation = float(str.strip (raw_input("Wha t will inflation average
over the next 30 years(.03, .04, etc): ")))

for x in xrange(30):
start = start*inflation +start
print start

inflation()
Jul 19 '05 #1
2 2261
rbt wrote:
Is this mathematically correct?
def inflation():
start = int(str.strip(r aw_input("How much money do you need each
month at the start of retirement: ")))
inflation = float(str.strip (raw_input("Wha t will inflation average
over the next 30 years(.03, .04, etc): ")))

for x in xrange(30):
start = start*inflation +start
print start

inflation()


The *arithmetic* is tedious but "correct" -- we won't concern ourselves
with rounding errors here. The *mathematics* might be better expressed as

required = start * (1.0 + inflation_rate_ per_period) ** number_of_perio ds
Jul 19 '05 #2
rbt wrote:
Is this mathematically correct?
def inflation():
start = int(str.strip(r aw_input("How much money do you need each
month at the start of retirement: ")))
inflation = float(str.strip (raw_input("Wha t will inflation average
over the next 30 years(.03, .04, etc): ")))

for x in xrange(30):
start = start*inflation +start
print start

inflation()


I'm not really familiar with financial calculations, but it looks
correct. There's a faster way though, since repeated multiplication is
the same as taking the power with the number of years as the exponent:

def inflation():
start = ... # same as before
inflation = ... # same as before

print start * (1+inflation)** 30
--
If I have been able to see further, it was only because I stood
on the shoulders of giants. -- Isaac Newton

Roel Schroeven
Jul 19 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
4468
by: Hans Gruber | last post by:
Hi all, I have been struggling with a problem all day, I have been unable to come up with a working solution. I want to write a function which takes 2 unix timestamps and calculates the difference. I want it to return the difference in years, months, days, hours, minutes and seconds (a complete summary). Keeping into account of course that these are 2 real dates, I dont want it to work with 30.475 as an average number of days in a...
7
2167
by: JLM | last post by:
I have a table that has fieldA, fieldB, fieldC. I want fieldC=fieldA-fieldB. simple enough. the next record I want to be able to do the same on the new value of fieldC. I can do this with SAP ABAP/4, but have never done this using Access. I'm sure this can be done, but not sure how to go about it. thanks in advance, jlm
0
356
by: Crimsonwingz | last post by:
I have a database that I wrote to show how much you will have in savings based on some given information: current balance current wage cost of living percent of salary to contribute per month percent return you are getting on savings year that you want to get projection on
3
12931
by: Ron Vecchi | last post by:
I need to calculate the age of a person based on a DateTime BirthDate I was thinking TimeSpan ts = DateTime.Now - BirthDate; //I can get the days but not years. // I could check each year from their year of birth, count the days in the year and compare with the days returned from timespan
33
8220
by: potassium flower | last post by:
I am trying to create a food order system for a restaurant. I have tried using both the DSum and Sum functions to calculate the total cost of an order. The total cost is a textbox on the form tblOrder (and a field in tblOrder) and the list of meals along with their costs are in the tblOrderDetail Subform (the columns in this form come fromt two tables - tblOrderDetails and tblItems). I have been putting the DSum / Sum in the control...
1
1809
by: Dineo | last post by:
Hi there I've created a database and a pivot table but I need to calculates percentages of all the WithdrwalAmt (the amount being withdrawn when retire) per PayeeName (where the money was invested after retirement, such as Investec) for each Scheme Name (Company name of the retiree). Please assist. Dineo
1
4808
by: karimufeed | last post by:
I am working on an access project for pension calculation. I want to generate the retirement date automatically at the age of 60 years while filling the date of Birth. i.e. if the Date of birth is 15/1/1950 then the date of retirement will be 31/1/2010 and if the date of birth is 01/1/1950 then the date of retirement will be 31/12/2009 one day earlier. Kindly help me how to generate the date of retirement by using VB code in an access project.
2
6236
by: bossenb6 | last post by:
I have an assignment to calculate depreciation using straight line, double declining balance and sum of the years digits. Heres what I have so far, but I can't seem to figure it out. Please help!! public class LabTest1Initialize { public static void main(String args) { // declare an integer (array) array with 6 rows (6 assets) // & 5 columns (5 attributes for each asset) int assetInfo = new int ;
0
8855
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8758
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8545
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8633
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6185
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5653
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
2762
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1986
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1743
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.