I plan to move into something to make games at a later date, but have been told I should learn the basics before messing with harder stuff and that if I have the basic’s learned I can pick up other languages much easier so I decided this class should work fine for now, right?

Ok so I am following along this YouTube MIT class on coding with Python. ( I am not allowed to post the link to the class apparently :-\)

I just finished watching lecture 3 and on the little assignment thing that comes with it, assignment one should be do-able because its " due " on lecture 4. basically its is about paying off a credit card debt for the time of one year.

(problem copy/pasted from the PDF)

Paying the Minimum

Problem 1

Write a program to calculate the credit card balance after one year if a person only pays the minimum monthly payment required by the credit card company each month.

Use raw_input() to ask for the following three floating point numbers:

1. the outstanding balance on the credit card

2. annual interest rate

3. minimum monthly payment rate

For each month, print the minimum monthly payment, remaining balance, principle paid in the format shown in the test cases below. All numbers should be rounded to the nearest penny. Finally, print the result, which should include the total amount paid that year and the remaining balance.

Test Case 1

>>>

Enter the outstanding balance on your credit card: 4800

Enter the annual credit card interest rate as a decimal: .2

Enter the minimum monthly payment rate as a decimal: .02

Month: 1

Minimum monthly payment: $96.0

Principle paid: $16.0

Remaining balance: $4784.0

Month: 2

Minimum monthly payment: $95.68

Principle paid: $15.95

Remaining balance: $4768.05

Month: 3

Minimum monthly payment: $95.36

Principle paid: $15.89

Remaining balance: $4752.16

Month: 4

Minimum monthly payment: $95.04

Principle paid: $15.84

Remaining balance: $4736.32

Month: 5

Minimum monthly payment: $94.73

Principle paid: $15.79

Remaining balance: $4720.53

Month: 6

Minimum monthly payment: $94.41

Principle paid: $15.73

Remaining balance: $4704.8

Month: 7

Minimum monthly payment: $94.1

Principle paid: $15.69

Remaining balance: $4689.11

Month: 8

Minimum monthly payment: $93.78

Principle paid: $15.63

Remaining balance: $4673.48

Month: 9

Minimum monthly payment: $93.47

Principle paid: $15.58

Remaining balance: $4657.9

Month: 10

Minimum monthly payment: $93.16

Principle paid: $15.53

Remaining balance: $4642.37

Month: 11

Minimum monthly payment: $92.85

Principle paid: $15.48

Remaining balance: $4626.89

Month: 12

Minimum monthly payment: $92.54

Principle paid: $15.43

Remaining balance: $4611.46

RESULT

Total amount paid: $1131.12

Remaining balance: $4611.46

ok so that is, what I assume, I should see when I run the program in Python.

Here the what I have typed so far:

x = float (raw_input (‘1. What is the outstanding balance on the credit card?:’))

y = float (raw_input (‘2. What is the annual intrest rate?:’))

z = float (raw_input (‘3. What is the minimum monthly payment rate?:’))

print ‘Month 1’

print ‘Minimum monthy payment: $’,(x*z)

a = (y/12.0*x)

b = (x*z)

print ‘Principal paid: $’, (b-a)

print ‘Remaining balance: $’, (x-(b-a))

My problems so far are:

1. I feel like I am doing this the hard way having so many letters = things. I know that my code does work for month 1 tho! lol

2. I don’t know how to continue down this path for the next few months. In month 2, I can no longer use x because my total balance will now be smaller.

3. I feel like I should be using " if ", " else ", and " while " statements in my code but not really sure how they fit in here.

I am not looking for the flat out answer, there is an answer key that comes with the assignments so if I am really 100% stuck I can open it up and see how it is coded. But I am trying to grasp the idea of it without just reading the code they used, I needed to be able to write my own and understand why it makes since. Any info would be appreciated. Thanks in advance!

Tweet This+ 1 thisPost To Linkedin