October 9th, 2013, 06:23 PM

Newbie question about strings and math using floats and ints.
Python is the first programming language I have tried to learn, so please bear with me. I am very new at this.
I am doing some exercises to try to find out how certain parts of Python work, and every time I think I know how to do something, I try some different things with it to see if I can use it in a scenario of my choosing. The short version is, why does the following code not work? I have successfully used floats before, and thought I had a good handle on them, but obviously not. So, what am I doing wrong?
Code:
#None of the crap below this line works right and IDK why.
#I specifically assigned the values to a floating point value to make Python do the math using floating point values on demand.
x = 34.0
y = 68.0
z = 240.0
print 'This is how to do floating point calculations with strings: if I multiply %d by %d and divide by %d, you get %d if you use the round() function to round the value to the nearest "int" value.' % (x, y, z, round(x * y / z)) # Apparently this is unnecessary as it's only rounding an int to an int, which is another way of saying it's rounding 9 into 9; it should be rounding 9.6333333333333333333333333333333 to 9.
print 'This produces a mathematical value as a "float": %d. Do you see how this is done?' % (x * y / z)
print 'This is how to do floating point calculations with strings: if I multiply %d by %d and divide by %d, you get %d if you use the round() function to round the value to the nearest "int" value.' % (x, y, z, round(x * y / z))
Tools I am using:
Notepad++ to do the coding work.
Powershell in Windows with Python installed to run .py files that I make.
I am using IDLE to test lines of code on the fly.
Python 2.7.
Thank you.
****EDIT: I figured it out. Nevermind.
Last edited by hypermagic2; October 9th, 2013 at 08:39 PM.
Reason: Issue Resolved.