Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed3a.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.001 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'python.': 0.02; 'float': 0.07; 'python3': 0.07; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'python': 0.11; 'wrote': 0.14; 'anyway': 0.14; '9.9': 0.16; '__future__': 0.16; 'calculator': 0.16; 'commented': 0.16; 'directive': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'reproduce': 0.16; 'seems': 0.21; '>>>': 0.22; 'import': 0.22; 'integer': 0.24; 'skip:n 60': 0.24; 'script': 0.25; 'header:X-Complaints-To:1': 0.27; "doesn't": 0.30; 'division': 0.31; 'subject:numbers': 0.31; 'class': 0.32; 'says': 0.33; 'received:co.za': 0.34; 'received:za': 0.34; 'version': 0.36; 'to:addr:python-list': 0.38; 'to:addr:python.org': 0.39; 'changed': 0.39; 'received:org': 0.40; 'number,': 0.60; 'show': 0.63; 'more': 0.64; 'natural': 0.68; 'frank': 0.68; 'received:41': 0.70; 'resistance': 0.84; 'divided': 0.91 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: "Frank Millman" Subject: Re: decimal numbers Date: Sat, 15 Feb 2014 12:04:17 +0200 References: <833583c7-c307-4ebf-9a60-3be146a565b5@googlegroups.com> X-Gmane-NNTP-Posting-Host: 41-133-114-46.dsl.mweb.co.za X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.3790.4657 X-RFC2646: Format=Flowed; Original X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.4913 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 47 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1392458669 news.xs4all.nl 2944 [2001:888:2000:d::a6]:39437 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:66400 "Luke Geelen" wrote in message news:ec88852e-1384-4aa5-834b-85135be94ab9@googlegroups.com... > Op zaterdag 15 februari 2014 10:18:36 UTC+1 schreef Luke Geelen: > hello, > > i have been working on a python resistor calculator to let my class show > what you can do with python. > > now i have a script that makes the more speekable value of the resistance > (res) > [...] > > i commented it because it doesn't work (yet), when i have a resistance of > > 9.9 Giga ohms it says it is 9 giga ohms. it seems to work with natural > number, anyway of using decimals insted so that it says : the resistance > is 9.9 Giga Ohms instead of 9 ? > You don't say which version of python you are using. If you are using python2, an integer divided by an integer always returns an integer - >>> 10/3 3 It was changed in python3 to return a float - >>> 10/3 3.3333333333333335 You can reproduce the python3 behaviour in python2 by adding a 'future' directive - >>> from __future__ import division >>> 10/3 3.3333333333333335 HTH Frank Millman