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

Hello all, again. So basically I'm just struggling with how to 'translate' something into python: I want to do "x" every month. So far my code for problem 1b is: balance = raw_input('Vot is the outstanding balance?') InrAn = raw_input('Vot is the annual interest rate as a decimal?') InrAn = float(InrAn) balance = float(balance) numMonths = 1 monthPay = 10 monthInr = InrAn/12.0 while balance >= 0 etc. I'm on the 1st problem that's been set, btw xD

OpenStudy (rsmith6559):

One thing that I'm not wild about is changing the type of data that balance and InrAn hold. You could put the entire raw_input() function into the float() function, like this: foo = float( raw_input( "Enter a decimal number: " ) ) raw_input() returns what the user entered as a string. When balance is started as a string, and then changed to a float after the float() function, it's neither pretty or possible in many other languages. One of the most important skills that a programmer needs to develop is to take a problem and break it down into smaller sub-problems and then break the sub-problems into sub-sub-problems and continue this until a small block of code, usually less than 20 lines, can solve this part of a problem. Breaking down ( decomposing ) a problem like this usually gives you the organization of the solution ( program ) too.

OpenStudy (hari5719):

google it

OpenStudy (anonymous):

First of all, it would help if your variable names were a bit more descriptive. As @rsmith6559 said, you can wrap your input with float() to clean it up and do it on one line for each of the inputs. Remember you must also input the minimum monthly payment. As far as the actual loop for problem 1 of problem set 1, you want to figure out the credit card balance after a year, so a for loop would work here. Inside the loop its simply arithmetic as outlined in the instructions: Minimum monthly payment = minimum monthly payment rate x remaining balance Interest paid = balance x interest rate / 12 Principal paid = Minimum monthly payment - interest paid Remaining balance = balance - principal I tried to be vague as to not give the whole problem away, so if you need more help let me know.

OpenStudy (anonymous):

Thanks. And yeah, I get how because I'm stuck on such a basic part it can be hard to give me hints!

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!
Latest Questions
GrezzyySista: Pics I took at a flower field
8 minutes ago 24 Replies 0 Medals
reginae: I'm giving out 5 gift subscription who should I give them to
6 minutes ago 21 Replies 4 Medals
Raye14: Idk whos my bf he didn't tell me his username
2 hours ago 0 Replies 0 Medals
Raye14: whos my bf he didn't tell me his username
2 hours ago 0 Replies 0 Medals
Raye14: If any want a personal art piece that's digital message me
3 hours ago 0 Replies 0 Medals
mybaelovesme: uk i hate how people say they wont leave then they do
3 hours ago 1 Reply 1 Medal
GothgirlLillian: Are piercings and/or tattoos considered art. If so which ones should I get?
35 seconds ago 7 Replies 1 Medal
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!