Quantcast

Got Homework?

Connect with other students for help. It's a free community.

  • across
    MIT Grad Student
    Online now
  • laura*
    Helped 1,000 students
    Online now
  • Hero
    College Math Guru
    Online now

Here's the question you clicked on:

55 members online
  • 0 replying
  • 0 viewing

PhilipY

Question on 6.00SC, problem set 1 question 1. This is the "Paying Off Credit Card Debt" problem. I initially ask the user to input their numbers. Then I used a for loop to run the 12 months. My first question is, how do I print a string and a float or integer on the same line? I'm getting an error message that you cannot concatenate separate types. For example, I am using this print code in my for loop: print 'Month: ' + x I designated x to be the number within the range of my for loop.

  • one year ago
  • one year ago

  • This Question is Closed
  1. PhilipY
    Best Response
    You've already chosen the best response.
    Medals 0

    My other question is.. How do I keep track of the total amount paid? My outstanding balance is within my for loop and the variable is constantly changing with each month. What I initially tried to do was to save the original outstanding balance by giving it another variable that I would save until the end. But I would get an error when trying to do this.

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

    With regard to your first question: if you want to print several variables on the same line, they can be seperated by a comma. So `print 'Month: ', x` should do the trick. (See: http://en.wikibooks.org/wiki/Python_Programming/Variables_and_Strings#Combining_Numbers_and_Strings) I'm not sure I fully understand your second question. Keeping track of something over a loop is best done with a seperate variable. Not sure if that's what you mean, though.

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

    Great thank you slotema. For the second question, I created a new variable = 0 and added it within my loop and got my total at the end. Thanks for your help!

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

    You're welcome.

    • one year ago
    • Attachments:

See more questions >>>

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.