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


Groups > comp.lang.python > #22163

Re: random number

From Peter Otten <__peter__@web.de>
Subject Re: random number
Date 2012-03-26 09:57 +0200
Organization None
References <CABgq=FyhR+Ldujj3YKRBpVXRVoeoayuXZviUUcNx-gXnFiHLSw@mail.gmail.com> <CACoeR0xV=28j6rFHm1ep3gzH9C0sbDqyxRRwX-JrVm3G+rrXww@mail.gmail.com> <CABgq=Fw_wQ3OVERStRdz5Nc=XKq9ji1RWpaM=ejUmg6j5TZHjQ@mail.gmail.com>
Newsgroups comp.lang.python
Message-ID <mailman.983.1332748631.3037.python-list@python.org> (permalink)

Show all headers | View raw


Nikhil Verma wrote:

> I want something to achieve like this :-
> 
> def random_number(id): # I am passing it from request
>     # do something
>     return random_number
> 
> Output
> 
> random_number(5)
> AXR670

That's normally not called a number (though it could be base 36 or similar).
 
> One input that is a number in return you are getting 6 digit alphanumeric
> string.
> 
> I tried this
> s = '%06d' % random.randint(0, 999999)
> 
> it gives : '192862' (a string )

Your question is not very clear. Can you give some more information, what 
you want to do with your "random" "number", and how the id argument should 
influence possible results, e. g. can the possible outcomes of 
random_number(x) and random_number(y) overlap for x != y?

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Re: random number Peter Otten <__peter__@web.de> - 2012-03-26 09:57 +0200

csiph-web