Quantcast

A community for students.

Here's the question you clicked on:

55 members online
  • 0 replying
  • 0 viewing

JocelynC

  • 2 years ago

Hello. A newbie is a little (very) confused on problem set 1 question 1, "Credit Card Debt." I watched lectures 1, 2 and the first recitation, and feel as if I understand them, so I may not know the necessary information. I'm actually a little confused...on where to start. This is my godawful attempt at starting the problem: x = float(raw_input('Enter current balance ')) y = float(raw_input('Enter annual interest rate ')) z = float(raw_input('Enter minimum monthly payment rate ')) for i in range(1,13): t = x * z p = (y/12.0) * x r = t - p b = x - r

  • This Question is Closed
  1. JocelynC
    • 2 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    x = b x = x print x I have no clue... before yesterday, the highest level programming I've done was on a TI-84...

  2. PhilipY
    • 2 years ago
    Best Response
    You've already chosen the best response.
    Medals 1

    The user raw input code looks good, and I did the for loop as well in this problem. Using the test case 1, after the 3 user inputs, they printed out "Month: 1", "Min monthly payment: " etc... So.. for i in range(1,13): print 'Month: ', i t = x * z print 'Minimum monthly payment: ', t etc.. all the equations in the loop look good, but I would change the last one, var b. Rather than using var b, I just used something like x = x - r So the balance changes itself. This is just the approach I took to the problem and I'm sure there are many ways to get the same results.

  3. shawnf
    • 2 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    i isn't used at all

  4. Gianko15
    • 2 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    Ok your code seems good, but you don't need to do: x = b x = x print x That's unnecessary, you just put after the for loop, "print b" or with some text to be more understandable for you and others, something like: print 'resultado:',b You can improve the for loop, you want to run over 12 times, just use: for i in range(12); When I started I confused putting the limits :$

  5. Gianko15
    • 2 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    Ask as many as you want, is better if you use less variables, cuz the less line code the better, but if your variables are like, rates, balance, etc; in that case where you would update them, will be usefull have each one in variables, is up to you most of the time. If you make x = 10.0/3; x = 3.3333333333, to round, just use: round(x,#ofDigits) -> round(x,2) = 3.33

  6. JocelynC
    • 2 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    Kay. Thanks :D!

  7. Gianko15
    • 2 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    you're welcome

  8. alternapop
    • 2 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    you might want to consider using variable names that give an idea about what they are used for. "balance" instead of "x", "interest_rate" instead of "y". it makes it easier to read and troubleshoot, both for you and those trying to help.

  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.