[Tutor] Strange issue output not showing up as floats

Jay Lozier jslozier at gmail.com
Sat Jun 21 20:29:35 CEST 2014


On 06/20/2014 07:59 PM, Deb Wyatt wrote:
> Hello.  I hope everyone is having a good day.  I am working on an assignment that is supposed to output floats.  I'm using floats in the computations and according to Python's rules the output should be floats, but it's not.  When I test in Python shell the calculations display correctly, as floats.
>
> I'm using Python 2.7 for this assignment.
>
> input is as follows  (not in code order):
> balance = 4213
> annualInterestRate = 0.2
> monthlyPaymentRate = 0.04
> payment = monthlyPaymentRate * balance
> balance = balance - payment
> total_paid = payment
>
> output looks like this:
>
> Month: 1
> Minimum monthly payment: 168
> Remaining balance: 4111
> Month: 2
> Minimum monthly payment: 164
> Remaining balance: 4013
> Month: 3
> Minimum monthly payment: 160
> Remaining balance: 3916
> ...etc...
>
> Would any of you have a clue what could be wrong?
> Deb in WA, USA
>
Deb,

Can you show us your full code listing or if it is lengthy the relevant 
section showing the print statement. My guess is your print formating is 
not specified correctly and it is rounding to the nearest whole number.

Jay

-- 
Jay Lozier
jslozier at gmail.com



More information about the Tutor mailing list