anonymous
  • anonymous
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.
MIT 6.00 Intro Computer Science (OCW)
schrodinger
  • schrodinger
I got my questions answered at brainly.com in under 10 minutes. Go to brainly.com now for free help!
At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga. Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus id quod maxime placeat facere possimus, omnis voluptas assumenda est, omnis dolor repellendus. Itaque earum rerum hic tenetur a sapiente delectus, ut aut reiciendis voluptatibus maiores alias consequatur aut perferendis doloribus asperiores repellat.

Get this expert

answer on brainly

SEE EXPERT ANSWER

Get your free account and access expert answers to this
and thousands of other questions

anonymous
  • anonymous
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.
anonymous
  • anonymous
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.
anonymous
  • anonymous
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!

Looking for something else?

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

More answers

anonymous
  • anonymous
You're welcome.

Looking for something else?

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