A community for students.

Here's the question you clicked on:

55 members online
  • 0 replying
  • 0 viewing

anonymous

  • one year ago

Homework 1 Part 2 Question: With the code down below I am trying to calculate how many months I need pay off the credit balance. The trouble I have is when I enter the input it output nothing. #Problem 2 balance = float(raw_input("Enter the outstanding balance on your credit card:")) year_int_rate = float(raw_input("Enter the annual credit card interest rate as a decimal:")) #Calculations monthpay = 10.0 month_int_rate = year_int_rate/12.0 month = 0 while balance > 0.0: month = month+1 balance = balance*(1+month_int_rate)-monthpay

  • This Question is Open
  1. rsmith6559
    • one year ago
    Best Response
    You've already chosen the best response.
    Medals 2

    In that code, there isn't any statement to output anything, so the computer doesn't output anything. Computers don't do what you want, they do EXACTLY what they're told to do. Right, wrong or indifferent.

  2. anonymous
    • one year ago
    Best Response
    You've already chosen the best response.
    Medals 0

    Just like rsmith6559 said, there is no output in the code, my middle school computer tech teacher always said; "Computers are stupid and sarcastic, they only do exactly what their supposed to do." Hopefully me and rsmith6559 helped you out.

  3. anonymous
    • one year ago
    Best Response
    You've already chosen the best response.
    Medals 0

    I forgot to attach the print statements that I had. Apparently there was a limit to how much text I used.

  4. anonymous
    • one year ago
    Best Response
    You've already chosen the best response.
    Medals 0

    Here is the rest of the code. #print results print "RESULT" print "Monthly payment to pay off debt in 1 year:", int(monthpay) print "Number of months needed:", month print "Balance:", round(balance, 2)

  5. rsmith6559
    • one year ago
    Best Response
    You've already chosen the best response.
    Medals 2

    I copied and pasted your code into a file on my machine. When I ran it, it ran fine. It printed out the results without change. Since you're having issues with the output, it begs the question, are you running it in Python2 or Python3 where print has changed from a statement to a function?

  6. anonymous
    • one year ago
    Best Response
    You've already chosen the best response.
    Medals 0

    I don't have Python 3 but Python 2.7. Although not having versions 2.5 or 2.6 may have resulted in not having an output.

  7. rsmith6559
    • one year ago
    Best Response
    You've already chosen the best response.
    Medals 2

    As long as you have Python2, you're fine. The differences between 2.5x, 2.6x and 2.7x are very minor. TBH, I've only run across them a couple of times, and I've been using Python since 1.51. Now it's getting interesting. Could you copy and paste the shell where you're running your program, please? Is the program hanging up, or is it returning without outputting anything? Could you post your code on PasteBin.com? Indentation is important in Python, and we need to see the code as written, not spread over two posts.

  8. anonymous
    • one year ago
    Best Response
    You've already chosen the best response.
    Medals 0

    Thanks for your help. I figured out what was wrong and it was my code.

  9. Not the answer you are looking for?
    Search for more explanations.

    • Attachments:

Ask your own question

Sign Up
Find more explanations on OpenStudy
Privacy Policy

Your question is ready. Sign up for free to start getting answers.

spraguer (Moderator)
5 → View Detailed Profile

is replying to Can someone tell me what button the professor is hitting...

23

  • Teamwork 19 Teammate
  • Problem Solving 19 Hero
  • You have blocked this person.
  • ✔ You're a fan Checking fan status...

Thanks for being so helpful in mathematics. If you are getting quality help, make sure you spread the word about OpenStudy.

This is the testimonial you wrote.
You haven't written a testimonial for Owlfred.