bussiness python

MRAB python at mrabarnett.plus.com
Tue Sep 5 21:03:42 EDT 2017


On 2017-09-06 01:40, timetowalk wrote:
> On Tuesday, September 5, 2017 at 8:28:00 PM UTC-4, MRAB wrote:
>> On 2017-09-05 22:21, jessicayates59 at gmail.com wrote:
>> > Here's a code that I have, i'm getting an error in line 5 and i'm not sure why,
>> > 
>> > 
>> > # future value of annuity
>> > p = 1000
>> > r = 2/100
>> > n = 5
>> > FV= p * ((1+r) ** n - 1/r)
>> > print(FV)
>> > 
>> [snip]
>> 
>> > the output is supposed to be
>> >   5204.0401600000005
>> [snip]
>> 
>> Your formula is wrong. The second closing parenthesis is in the wrong place.
>> 
>> That line should be:
>> 
>> FV = p * ((1 + r) ** n - 1) / r
> 
> 
> 
> For line #3, r = 2/100 is zero.
> For line #5, 1/r will cause an exception
> 
The error wasn't specified.

The print lines have parentheses, which is suggestive of Python 3. If it 
was Python 2, those lines probably wouldn't have the parentheses.



More information about the Python-list mailing list