[Microbit-Python] 5/2

Michael sparks.m at gmail.com
Sat Dec 10 10:54:30 EST 2016


On 10 December 2016 at 11:42, Sven Turnau via Microbit <microbit at python.org>
wrote:

> In python IDE
>

Which python IDE do you mean?

It sounds like the python IDE you're using is python 2 based. (eg python
2.7)

Micropython is an implementation of python 3.

There are slight differences between python 2 and python 3.

> I have 5/2 result is 2 not 2.5 as in micropython??
> Is it an BUG??

No, it's an example of one difference between python 2 and python 3.

Python 2 uses the rule *"5 is an integer, 2 is an integer, so we'll have
the result as an integer"* (Which since 5 is odd, it chops off the decimal
part)

Python 3 uses the rule *"Python 2 had a confusing result, so let's give a
result that people expect from normal maths instead"* :-)

Hope that helps,


Michael.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/microbit/attachments/20161210/01f511aa/attachment.html>


More information about the Microbit mailing list