Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #78691
| Path | csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!us.feeder.erje.net!newsfeed.fsmpi.rwth-aachen.de!weretis.net!feeder4.news.weretis.net!newsreader4.netcologne.de!news.netcologne.de!bcyclone05.am1.xlned.com!bcyclone05.am1.xlned.com!news.astraweb.com!border5.a.newsrouter.astraweb.com!not-for-mail |
|---|---|
| From | Seymore4Head <Seymore4Head@Hotmail.invalid> |
| Newsgroups | comp.lang.python |
| Subject | A little more: decimal_portion |
| Date | Sat, 04 Oct 2014 10:58:52 -0400 |
| Message-ID | <2p203aldkhli65bd9crd4ljbfuab0u90oc@4ax.com> (permalink) |
| X-Newsreader | Forte Agent 4.2/32.1118 |
| MIME-Version | 1.0 |
| Content-Type | text/plain; charset=us-ascii |
| Content-Transfer-Encoding | 7bit |
| Lines | 15 |
| Organization | Unlimited download news at news.astraweb.com |
| NNTP-Posting-Host | a3ce05ac.news.astraweb.com |
| X-Trace | DXC=1_16G0^cPo5aTZ9_0GJc??L?0kYOcDh@:U^I3MRbi=k17hYWEOcT^f7l9B_G1R=S=7<>a^elBcbL9L\a2J2U=lb>>;G_[[=?VT6D<oXhDnX;N7E\LhO>fFbk; |
| X-Received-Bytes | 1162 |
| X-Received-Body-CRC | 4162654412 |
| Xref | csiph.com comp.lang.python:78691 |
Show key headers only | View raw
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.
Back to comp.lang.python | Previous | Next — 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