Ask your own question, for FREE!
MIT 6.00 Intro Computer Science (OCW) 20 Online
OpenStudy (anonymous):

I am studying code that writes a program to calculate monthly interest rates for credit card debt. There is a integer that I don't understand it's purpose and just wondering what it represents. It is the only "2" in the code below ... while numMonths <= 12: # Minimum monthly payment of balance at start of the month minPayment = round(minMonthlyPaymentRate * balance,2) totalAmtPaid += minPayment

OpenStudy (doc.brown):

What language is it? I'm not sure exactly, but I imagine the function round() has two inputs separated by the comma. round(number to be rounded, decimal places to round to) In this case a 2 would give you 12.34 from 12.3455678

OpenStudy (anonymous):

Thanks! that would make a lot of sense. I'm writing in Python.

OpenStudy (doc.brown):

OK then, in Python round(number[, ndigits]) The number of digits is the decimal places. If you omit ndigits it defaults to 0

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!