Code not running. Help!

This is the place for queries that don't fit in any of the other categories.

Code not running. Help!

Postby Tuckin » Thu Feb 21, 2013 11:43 am

Code: Select all
# a Python program to calculate mortgage payments and mortgage costs
print("This is a comprehensive mortgage payment calculator.")
print("It is a quick and easy way to work out your monthly mortgage payments and find out how much you can afford before you borrow.")

print("*"*80)

responses = ["Yes", "No"]


##while True:
response = input("Enter Yes to continue or No to exit: ")

if response == "Yes":
       print("*"*80)
       
else:
       print(("You may now exit")

       while True:
             
    # give total loan
             
       propertyvalue = float(input("Please enter estimated property value: "))
    # deposit value
deposit = float(input("Enter deposit value: "))
   
mortgage = propertyvalue - deposit
    # give annual percent interest
rate = float(input("Please enter rate: "))
    # calculate monthly interest rate
monthly_interest = rate/(100 * 12)
    # give length of mortgage
years = int(input("Please enter mortgage term: "))

    # give payments made
payments = int(input("Please enter number of payments made: "))

    # calculate total number of payments
payment_number = years * 12

monthly_payment = mortgage * ( monthly_interest / (1 - (1 + monthly_interest) ** (- payment_number)))

   
print ("Total loan = £%0.2f" % mortgage)
print ("Interest = %0.2f%s" % (rate, "%"))
print ("Years = %0.f" % years)
print ("Number of payments = %0.f" % payment_number)
print ("Monthly payment amount = £%0.2f" % monthly_payment)
   
print ("="*80)
   
print ("Total cost = £%0.2f" % (payment_number * monthly_payment))
print ("Total interest = £%0.2f" % (payment_number * monthly_payment - mortgage))
   
print ("="*80)
   


   
rem_mortgage = mortgage * (1 - ((1 + monthly_interest) ** payments - 1) / ((1 + monthly_interest) ** payment_number - 1))
   
   
print ("The outstanding mortgage value after %d payments is £%0.2f" % (payments, rem_mortgage))
print ("Payment made till date is a total of £%0.2f" % (monthly_payment * payments))
Tuckin
 
Posts: 1
Joined: Thu Feb 21, 2013 11:41 am

Re: Code not running. Help!

Postby stranac » Thu Feb 21, 2013 12:21 pm

I've edited your post(corrected code tags and such), but please read this carefully before posting again.

Also, it might be easier to help you if you explain exactly what problem you're getting, and paste the entire error traceback if you get any.
All I can see for now is your indentation makes no sense, and you're missing a closing paren before the 'while True:' line.
Friendship is magic!

R.I.P. Tracy M. You will be missed.
User avatar
stranac
 
Posts: 1111
Joined: Thu Feb 07, 2013 3:42 pm


Return to General Coding Help

Who is online

Users browsing this forum: No registered users and 4 guests