Floor value in math operators
Chris Rebert
clp2 at rebertia.com
Wed Apr 8 12:08:40 EDT 2009
On Wed, Apr 8, 2009 at 9:03 AM, Avi <avinashrude at gmail.com> wrote:
> Hi,
>
> This will be a very simple question to ask all the awesome programmers
> here:
>
> How can I get answer in in decimals for such a math operator:
>
> 3/2
>
> I get 1. I want to get 1.5
Add the following line to the top of your program (or use Python 3.0+):
from __future__ import division
To get integer division when this is enabled, use the integer division
operator, //
e.g. x = 3//2 #x=1
Cheers,
Chris
--
I have a blog:
http://blog.rebertia.com
More information about the Python-list
mailing list