Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > de.comp.lang.python > #4741

[Python-de] Warum liefert // ein float?

Path csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail
From Florian Lindner <mailinglists@xgm.de>
Newsgroups de.comp.lang.python
Subject [Python-de] Warum liefert // ein float?
Date Thu, 6 Apr 2017 09:52:44 +0200
Lines 26
Message-ID <mailman.169.1491465173.2961.python-de@python.org> (permalink)
References <ea8deb7d-44d8-4f77-3922-90e41b49a439@xgm.de>
Mime-Version 1.0
Content-Type text/plain; charset=utf-8
Content-Transfer-Encoding 8bit
X-Trace news.uni-berlin.de TQyBMLL6QDujI1uOMkZ60QcBFOhn5P1xzDZ7r27LXe0A==
Return-Path <mailinglists@xgm.de>
X-Original-To python-de@python.org
Delivered-To python-de@mail.python.org
User-Agent Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.0
Content-Language en-US
X-BeenThere python-de@python.org
X-Mailman-Version 2.1.23
Precedence list
List-Id Die Deutsche Python Mailingliste <python-de.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-de>, <mailto:python-de-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-de/>
List-Post <mailto:python-de@python.org>
List-Help <mailto:python-de-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-de>, <mailto:python-de-request@python.org?subject=subscribe>
X-Mailman-Original-Message-ID <ea8deb7d-44d8-4f77-3922-90e41b49a439@xgm.de>
Xref csiph.com de.comp.lang.python:4741

Show key headers only | View raw


Hallo,

Python 3.6.0 (default, Jan 16 2017, 12:12:55)

>>> x = 3.5
>>> y = 2.5
>>> x // y
1.0

>>> type(x // y)
<class 'float'>

>>> range(x // y)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: 'float' object cannot be interpreted as an integer

Warum liefert // ein float zurück, obwohl das Ergebnis, immer eine eine Ganzzahl ist (in dem Sinne, dass es keine
Nachkommestellen hat)?

Damit ich da raus eine range machen kann, brauche ich wieder int(.), dann kann ich aber gleich auf // verzichten.

Nur mal Interesse halber...

Grüße,
Florian

Back to de.comp.lang.python | Previous | Next | Find similar


Thread

[Python-de] Warum liefert // ein float? Florian Lindner <mailinglists@xgm.de> - 2017-04-06 09:52 +0200

csiph-web