Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #22167
| Path | csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.mixmin.net!eweka.nl!hq-usenetpeers.eweka.nl!xlned.com!feeder7.xlned.com!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <python-python-list@m.gmane.org> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.026 |
| X-Spam-Evidence | '*H*': 0.95; '*S*': 0.00; '>>>>': 0.09; 'subject:number': 0.09; 'random': 0.13; 'print': 0.15; '*is*': 0.16; 'enigma': 0.16; 'kern': 0.16; 'received:80.91': 0.16; 'received:80.91.229': 0.16; 'received:gmane.org': 0.16; 'received:list': 0.16; 'subject:random': 0.16; 'underlying': 0.16; 'robert': 0.18; 'def': 0.20; 'wrote:': 0.21; 'i.e.': 0.22; 'odd': 0.22; 'header:In-Reply-To:1': 0.22; 'header:User-Agent:1': 0.23; '>>>': 0.24; 'this?': 0.24; 'suspect': 0.29; 'skip:( 30': 0.34; 'knows': 0.35; 'really': 0.36; "i'm": 0.36; 'sure': 0.36; 'header:X-Complaints-To:1': 0.36; 'but': 0.36; 'something': 0.38; 'received:org': 0.38; 'to:addr:python-list': 0.39; 'how': 0.40; 'to:addr:python.org': 0.40; 'request.': 0.62; 'fact,': 0.63; 'our': 0.64; 'world': 0.65; 'believe': 0.67; 'digits?': 0.84; 'generator.': 0.84; 'terrible': 0.84; 'eco': 0.91 |
| X-Injected-Via-Gmane | http://gmane.org/ |
| To | python-list@python.org |
| From | Robert Kern <robert.kern@gmail.com> |
| Subject | Re: random number |
| Date | Mon, 26 Mar 2012 10:36:12 +0100 |
| References | <CABgq=FyhR+Ldujj3YKRBpVXRVoeoayuXZviUUcNx-gXnFiHLSw@mail.gmail.com> <mailman.980.1332744526.3037.python-list@python.org> <4f7019b6$0$29968$c3e8da3$5496439d@news.astraweb.com> <jkp73e$9qd$1@mx1.internetia.pl> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=ISO-8859-1; format=flowed |
| Content-Transfer-Encoding | 7bit |
| X-Gmane-NNTP-Posting-Host | 94.197.127.115.threembb.co.uk |
| User-Agent | Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7; rv:11.0) Gecko/20120313 Thunderbird/11.0 |
| In-Reply-To | <jkp73e$9qd$1@mx1.internetia.pl> |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.12 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <http://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 | <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.988.1332754589.3037.python-list@python.org> (permalink) |
| Lines | 35 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1332754589 news.xs4all.nl 6855 [2001:888:2000:d::a6]:45099 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:22167 |
Show key headers only | View raw
On 3/26/12 8:50 AM, Grzegorz Staniak wrote:
> On 26.03.2012, Steven D'Aprano<steve+comp.lang.python@pearwood.info> wroted:
>
>>>> How can we generate a 6 digit random number from a given number ?
>>> what about this?
>>>
>>>>>> given_number=123456
>>>>>> def rand_given_number(x):
>>> ... s = list(str(x))
>>> ... random.shuffle(s)
>>> ... return int(''.join(s))
>>> ...
>>>>>> print (rand_given_number(given_number))
>>> 653421
>>
>>
>> That's not very random. In fact, it is *terrible* as a random number
>> generator.
>
> But isn't it what the OP requested, i.e. "6 digit random number
> *from a given number*"? That is, a random permutation of the set
> of its digits?
I would consider that to be a very odd interpretation of that request. But it
*is* an extraordinarily vague request. I'm not sure if even the OP knows what he
wants. I suspect he really wants something like a hash.
--
Robert Kern
"I have come to believe that the whole world is an enigma, a harmless enigma
that is made terrible by our own mad attempt to interpret it as though it had
an underlying truth."
-- Umberto Eco
Back to comp.lang.python | Previous | Next — Previous in thread | Find similar | Unroll thread
Re: random number Michael Poeltl <michael.poeltl@univie.ac.at> - 2012-03-26 08:40 +0200
Re: random number Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-03-26 07:24 +0000
Re: random number Grzegorz Staniak <gstaniak@gmail.com> - 2012-03-26 07:50 +0000
Re: random number Robert Kern <robert.kern@gmail.com> - 2012-03-26 10:36 +0100
csiph-web