Talk:Python Programming/Basic Math

Running the programme
When I run this programme:

The output I get is in an integer format. For example: What is your mass in kilograms?71 You weigh 11 stone.

When I changed the programme to read

Then I get the long string of numbers after the decimal point: What is your mass in kilograms?71 You weigh 11.1571428571 stone.

The rest of the suggested changes work well when I make this change. Should the programme say %s or is this some sort of quirk on the computer I am using (an apple mac running OS X)? Wobble (talk) 09:40, 29 May 2008 (UTC)


 * "%s" treats the variable mass_stone as a string rather than a float or integer, when combined with the % operator. Because of how Python works, it is autocasted from a float.  See the Python documentation for more information. --Sigma 7 (talk) 15:24, 11 February 2010 (UTC)

note from another user: the program terminates too fast. i can't seem to fix it. —Preceding unsigned comment added by 2l0t0k9 (discuss • contribs) 15:50, 8 February 2010


 * If "terminates too fast" means the window is closing before you can read the output, you're launching it wrong. Either use an interactive interpreter (such as IDLE), or run it from a command prompt. --Sigma 7 (talk) 15:24, 11 February 2010 (UTC)

What am I doing wrong?
I've tried everyting. It's probably something blatantly obvious. --71.136.41.121 (discuss) 20:41, 5 January 2012 (UTC)

I believe you forgot the commas in the print command. Correct code is: --Patrick95350 (discuss • contribs) 19:52, 20 February 2012 (UTC)