Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #78692
| Path | csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed2.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <rosuav@gmail.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.011 |
| X-Spam-Evidence | '*H*': 0.98; '*S*': 0.00; 'parameters': 0.04; 'float': 0.07; 'intermediate': 0.07; 'parameter': 0.09; 'second.': 0.09; 'cc:addr:python-list': 0.11; 'def': 0.12; 'doing,': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'wrote:': 0.18; 'portion': 0.22; 'cc:addr:python.org': 0.22; 'print': 0.22; 'cc:2**0': 0.24; 'compare': 0.26; '(for': 0.26; 'header:In-Reply-To:1': 0.27; 'function': 0.29; 'am,': 0.29; 'message-id:@mail.gmail.com': 0.30; 'skip:( 20': 0.30; 'decimal': 0.31; 'supposed': 0.32; 'skip:d 20': 0.34; 'received:google.com': 0.35; 'subject:skip:d 10': 0.36; 'doing': 0.36; 'example,': 0.37; 'two': 0.37; 'step': 0.37; 'little': 0.38; 'expect': 0.39; 'first': 0.61; 'subject:more': 0.64; 'more:': 0.84; 'url:imgur': 0.84; 'step.': 0.91; 'to:none': 0.92 |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:cc :content-type; bh=1ek0hP1LmGgs3XufgYCOhofm5cFSgcyjoR2dc53JW9w=; b=hoo9upriqm3xPq4K52JFovRR+3DoKBJNb1JVxnoCcnOUuYCFDQxAGEKzXcCSoa/nq/ H9ZUNov6Lf7nEXGuiarxdaXIeoA6dqE00dwAynBWLhVySce2pypYf+eDTLqs38Dzvqak WcG/eSpvT39fuE8bfx6H5ncsJibVd9/ze5ovFUVQKl0SCXSPq8+g7WrxzbK7p1ictMv6 sn8RDCfIws1V36twt1NUCPEaZFFhWYK2r0+U8yzJiMXT2shi3KRtWmjLIN70OGHPRa0t UNxPvyOQB32Mt9m9rg6im8yOjPFrcGschFJmOu5qi3zlXY4wKDo75dwWjrdft50w/tWi rzjg== |
| MIME-Version | 1.0 |
| X-Received | by 10.50.20.169 with SMTP id o9mr7012267ige.14.1412435259380; Sat, 04 Oct 2014 08:07:39 -0700 (PDT) |
| In-Reply-To | <2p203aldkhli65bd9crd4ljbfuab0u90oc@4ax.com> |
| References | <2p203aldkhli65bd9crd4ljbfuab0u90oc@4ax.com> |
| Date | Sun, 5 Oct 2014 01:07:39 +1000 |
| Subject | Re: A little more: decimal_portion |
| From | Chris Angelico <rosuav@gmail.com> |
| Cc | "python-list@python.org" <python-list@python.org> |
| Content-Type | text/plain; charset=UTF-8 |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.15 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list/> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.14599.1412435262.18130.python-list@python.org> (permalink) |
| Lines | 24 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1412435262 news.xs4all.nl 2973 [2001:888:2000:d::a6]:36972 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:78692 |
Show key headers only | View raw
On Sun, Oct 5, 2014 at 12:58 AM, Seymore4Head <Seymore4Head@hotmail.invalid> wrote: > A little more: decimal_portion > > Write a function that takes two number parameters and returns a float > that is the decimal portion of the result of dividing the first > parameter by the second. (For example, if the parameters are 5 and 2, > the result of 5/2 is 2.5, so the return value would be 0.5) > > http://imgur.com/a0Csi43 > > def decimal_portion(a,b): > return float((b/a)-((b//a))) > > print (decimal_portion(5,2)) > > I get 0.4 and the answer is supposed to be 0.5. Work out exactly what your program is doing, step by step. Print out the intermediate steps in the calculation, and compare what the program's doing to what you expect to be happening. What's (b/a)? What's (b//a)? What's (b/a)-((b//a))? ChrisA
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
A little more: decimal_portion Seymore4Head <Seymore4Head@Hotmail.invalid> - 2014-10-04 10:58 -0400
Re: A little more: decimal_portion Chris Angelico <rosuav@gmail.com> - 2014-10-05 01:07 +1000
Re: A little more: decimal_portion Seymore4Head <Seymore4Head@Hotmail.invalid> - 2014-10-04 11:16 -0400
Re: A little more: decimal_portion Chris Angelico <rosuav@gmail.com> - 2014-10-05 01:24 +1000
Re: A little more: decimal_portion Seymore4Head <Seymore4Head@Hotmail.invalid> - 2014-10-04 11:38 -0400
Re: A little more: decimal_portion Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-10-05 01:46 +1000
Re: A little more: decimal_portion Seymore4Head <Seymore4Head@Hotmail.invalid> - 2014-10-04 12:11 -0400
Re: A little more: decimal_portion wxjmfauth@gmail.com - 2014-10-05 00:14 -0700
csiph-web