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


Groups > comp.lang.python > #45867 > unrolled thread

help how to sort a list in order of 'n' in python without using inbuilt functions??

Started bylokeshkoppaka@gmail.com
First post2013-05-24 01:04 -0700
Last post2013-05-25 17:59 +0300
Articles 20 on this page of 42 — 11 participants

Back to article view | Back to comp.lang.python


Contents

  help how to sort a list in order of 'n' in python without using inbuilt functions?? lokeshkoppaka@gmail.com - 2013-05-24 01:04 -0700
    Re: help how to sort a list in order of 'n' in python without using inbuilt functions?? Chris Angelico <rosuav@gmail.com> - 2013-05-24 18:12 +1000
    Re: help how to sort a list in order of 'n' in python without using inbuilt functions?? Dave Angel <davea@davea.name> - 2013-05-24 08:33 -0400
    RE: help how to sort a list in order of 'n' in python without using inbuilt functions?? Carlos Nepomuceno <carlosnepomuceno@outlook.com> - 2013-05-24 16:06 +0300
    Re: help how to sort a list in order of 'n' in python without using inbuilt functions?? lokeshkoppaka@gmail.com - 2013-05-24 22:15 -0700
      Re: help how to sort a list in order of 'n' in python without using inbuilt functions?? Chris Angelico <rosuav@gmail.com> - 2013-05-25 15:24 +1000
        Re: help how to sort a list in order of 'n' in python without using inbuilt functions?? lokeshkoppaka@gmail.com - 2013-05-24 22:39 -0700
          Re: help how to sort a list in order of 'n' in python without using inbuilt functions?? Chris Angelico <rosuav@gmail.com> - 2013-05-25 15:43 +1000
          Re: help how to sort a list in order of 'n' in python without using inbuilt functions?? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-05-25 05:57 +0000
            Re: help how to sort a list in order of 'n' in python without using inbuilt functions?? lokeshkoppaka@gmail.com - 2013-05-24 23:05 -0700
              Re: help how to sort a list in order of 'n' in python without using inbuilt functions?? Chris Angelico <rosuav@gmail.com> - 2013-05-25 16:12 +1000
              RE: help how to sort a list in order of 'n' in python without using inbuilt functions?? Carlos Nepomuceno <carlosnepomuceno@outlook.com> - 2013-05-25 10:53 +0300
              Re: help how to sort a list in order of 'n' in python without using inbuilt functions?? Chris Angelico <rosuav@gmail.com> - 2013-05-25 18:28 +1000
              RE: help how to sort a list in order of 'n' in python without using inbuilt functions?? Carlos Nepomuceno <carlosnepomuceno@outlook.com> - 2013-05-25 11:43 +0300
              Re: help how to sort a list in order of 'n' in python without using inbuilt functions?? Chris Angelico <rosuav@gmail.com> - 2013-05-25 18:47 +1000
              RE: help how to sort a list in order of 'n' in python without using inbuilt functions?? Carlos Nepomuceno <carlosnepomuceno@outlook.com> - 2013-05-25 11:54 +0300
              Re: help how to sort a list in order of 'n' in python without using inbuilt functions?? Chris Angelico <rosuav@gmail.com> - 2013-05-25 19:01 +1000
              RE: help how to sort a list in order of 'n' in python without using inbuilt functions?? Carlos Nepomuceno <carlosnepomuceno@outlook.com> - 2013-05-25 12:10 +0300
              Re: help how to sort a list in order of 'n' in python without using inbuilt functions?? Chris Angelico <rosuav@gmail.com> - 2013-05-25 19:14 +1000
                Re: help how to sort a list in order of 'n' in python without using inbuilt functions?? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-05-25 14:28 +0000
                  Re: help how to sort a list in order of 'n' in python without using inbuilt functions?? Fábio Santos <fabiosantosart@gmail.com> - 2013-05-25 15:46 +0100
                  Re: help how to sort a list in order of 'n' in python without using inbuilt functions?? Mark Lawrence <breamoreboy@yahoo.co.uk> - 2013-05-25 16:03 +0100
                  Re: help how to sort a list in order of 'n' in python without using inbuilt functions?? Chris Angelico <rosuav@gmail.com> - 2013-05-26 01:41 +1000
                    Re: help how to sort a list in order of 'n' in python without using inbuilt functions?? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-05-26 03:09 +0000
                      Re: help how to sort a list in order of 'n' in python without using inbuilt functions?? Chris Angelico <rosuav@gmail.com> - 2013-05-26 14:02 +1000
                  RE: help how to sort a list in order of 'n' in python without using inbuilt functions?? Carlos Nepomuceno <carlosnepomuceno@outlook.com> - 2013-05-25 20:12 +0300
                  RE: help how to sort a list in order of 'n' in python without using inbuilt functions?? Carlos Nepomuceno <carlosnepomuceno@outlook.com> - 2013-05-25 20:17 +0300
                  Re: help how to sort a list in order of 'n' in python without using inbuilt functions?? Chris Angelico <rosuav@gmail.com> - 2013-05-26 03:23 +1000
                    Re: help how to sort a list in order of 'n' in python without using inbuilt functions?? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-05-26 03:38 +0000
                      Re: help how to sort a list in order of 'n' in python without using inbuilt functions?? Dan Sommers <dan@tombstonezero.net> - 2013-05-26 04:06 +0000
                      Re: help how to sort a list in order of 'n' in python without using inbuilt functions?? Chris Angelico <rosuav@gmail.com> - 2013-05-26 14:28 +1000
                  RE: help how to sort a list in order of 'n' in python without using inbuilt functions?? Carlos Nepomuceno <carlosnepomuceno@outlook.com> - 2013-05-25 20:34 +0300
              RE: help how to sort a list in order of 'n' in python without using inbuilt functions?? Carlos Nepomuceno <carlosnepomuceno@outlook.com> - 2013-05-25 12:30 +0300
              Re: help how to sort a list in order of 'n' in python without using inbuilt functions?? Mark Lawrence <breamoreboy@yahoo.co.uk> - 2013-05-25 13:01 +0100
              Re: help how to sort a list in order of 'n' in python without using inbuilt functions?? Roy Smith <roy@panix.com> - 2013-05-25 10:03 -0400
                Re: help how to sort a list in order of 'n' in python without using inbuilt functions?? Dave Angel <davea@davea.name> - 2013-05-25 10:27 -0400
              Re: help how to sort a list in order of 'n' in python without using inbuilt functions?? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-05-25 14:30 +0000
              RE: help how to sort a list in order of 'n' in python without using inbuilt functions?? Carlos Nepomuceno <carlosnepomuceno@outlook.com> - 2013-05-25 20:07 +0300
              RE: help how to sort a list in order of 'n' in python without using inbuilt functions?? Carlos Nepomuceno <carlosnepomuceno@outlook.com> - 2013-05-25 20:45 +0300
      Re: help how to sort a list in order of 'n' in python without using inbuilt functions?? rusi <rustompmody@gmail.com> - 2013-05-24 22:43 -0700
      Re: help how to sort a list in order of 'n' in python without using inbuilt functions?? Roy Smith <roy@panix.com> - 2013-05-25 09:29 -0400
        Re: help how to sort a list in order of 'n' in python without using inbuilt functions?? Jussi Piitulainen <jpiitula@ling.helsinki.fi> - 2013-05-25 17:59 +0300

Page 1 of 3  [1] 2 3  Next page →


#45867 — help how to sort a list in order of 'n' in python without using inbuilt functions??

Fromlokeshkoppaka@gmail.com
Date2013-05-24 01:04 -0700
Subjecthelp how to sort a list in order of 'n' in python without using inbuilt functions??
Message-ID<e31fbc7c-1bc0-4f9a-9f1d-68f963a9ec39@googlegroups.com>
i need to write a code which can sort the list in order of 'n' without use builtin functions 
can anyone help me how to do?

[toc] | [next] | [standalone]


#45868

FromChris Angelico <rosuav@gmail.com>
Date2013-05-24 18:12 +1000
Message-ID<mailman.2050.1369383168.3114.python-list@python.org>
In reply to#45867
On Fri, May 24, 2013 at 6:04 PM,  <lokeshkoppaka@gmail.com> wrote:
> i need to write a code which can sort the list in order of 'n' without use builtin functions
> can anyone help me how to do?
> --
> http://mail.python.org/mailman/listinfo/python-list

http://lmgtfy.com/?q=sorting+algorithm
http://www.catb.org/esr/faqs/smart-questions.html

ChrisA

[toc] | [prev] | [next] | [standalone]


#45880

FromDave Angel <davea@davea.name>
Date2013-05-24 08:33 -0400
Message-ID<mailman.2057.1369398850.3114.python-list@python.org>
In reply to#45867
On 05/24/2013 04:04 AM, lokeshkoppaka@gmail.com wrote:
> i need to write a code which can sort the list in order of 'n' without use builtin functions
> can anyone help me how to do?
>

You could sort, but you couldn't print out the results, so what's the 
point?  In Python 3.3 at least, print() is a built-in function.

Is the homework assignment more clearly worded than your summary?  And 
if so, how far have you gotten on it?

-- 
DaveA

[toc] | [prev] | [next] | [standalone]


#45882

FromCarlos Nepomuceno <carlosnepomuceno@outlook.com>
Date2013-05-24 16:06 +0300
Message-ID<mailman.2063.1369400827.3114.python-list@python.org>
In reply to#45867
lol wtf?

If 'n' is the quantity of elements to be sorted there's 
no way you can write an algorithm with complexity O(n) for the worst 
case not knowing something special about the data.

For example, Quicksort will give you O(n*(log(n)) on average case (O(n^2) in the worst case).

You gotta be much more specific than that if you really need an O(n) code.

There's probably assumptions you didn't mention about the data if O(n) it's really what you're looking for.

PS: Looks like a joke as stated..

----------------------------------------
> Date: Fri, 24 May 2013 01:04:51 -0700
> Subject: help how to sort a list in order of 'n' in python without using inbuilt functions??
> From: lokeshkoppaka@gmail.com
> To: python-list@python.org
>
> i need to write a code which can sort the list in order of 'n' without use builtin functions
> can anyone help me how to do?
> --
> http://mail.python.org/mailman/listinfo/python-list 		 	   		  

[toc] | [prev] | [next] | [standalone]


#45961

Fromlokeshkoppaka@gmail.com
Date2013-05-24 22:15 -0700
Message-ID<78192328-b31b-49d9-9cd6-ec742c092a29@googlegroups.com>
In reply to#45867
On Friday, May 24, 2013 1:34:51 PM UTC+5:30, lokesh...@gmail.com wrote:
> i need to write a code which can sort the list in order of 'n' without use builtin functions 
> 
> can anyone help me how to do?

 Note:
the list only contains 0's,1's,2's
need to sort them in order of 'n'

[toc] | [prev] | [next] | [standalone]


#45962

FromChris Angelico <rosuav@gmail.com>
Date2013-05-25 15:24 +1000
Message-ID<mailman.2109.1369459444.3114.python-list@python.org>
In reply to#45961
On Sat, May 25, 2013 at 3:15 PM,  <lokeshkoppaka@gmail.com> wrote:
> On Friday, May 24, 2013 1:34:51 PM UTC+5:30, lokesh...@gmail.com wrote:
>> i need to write a code which can sort the list in order of 'n' without use builtin functions
>>
>> can anyone help me how to do?
>
>  Note:
> the list only contains 0's,1's,2's
> need to sort them in order of 'n'

In that case, you're not really ordering them, you're counting them.
Look at the collections module; you can very easily figure out how
many of each there are, and then reconstruct the list afterward.

ChrisA

[toc] | [prev] | [next] | [standalone]


#45964

Fromlokeshkoppaka@gmail.com
Date2013-05-24 22:39 -0700
Message-ID<39ac7437-857e-483f-998c-8162c1039933@googlegroups.com>
In reply to#45962
On Saturday, May 25, 2013 10:54:01 AM UTC+5:30, Chris Angelico wrote:
> On Sat, May 25, 2013 at 3:15 PM,  <lokeshkoppaka@gmail.com> wrote:
> 
> > On Friday, May 24, 2013 1:34:51 PM UTC+5:30, lokesh...@gmail.com wrote:
> 
> >> i need to write a code which can sort the list in order of 'n' without use builtin functions
> 
> >>
> 
> >> can anyone help me how to do?
> 
> >
> 
> >  Note:
> 
> > the list only contains 0's,1's,2's
> 
> > need to sort them in order of 'n'
> 
> 
> 
> In that case, you're not really ordering them, you're counting them.
> 
> Look at the collections module; you can very easily figure out how
> 
> many of each there are, and then reconstruct the list afterward.
> 
> 
> 
> ChrisA

but i need to do it with out using builtin functions

[toc] | [prev] | [next] | [standalone]


#45966

FromChris Angelico <rosuav@gmail.com>
Date2013-05-25 15:43 +1000
Message-ID<mailman.2111.1369460620.3114.python-list@python.org>
In reply to#45964
On Sat, May 25, 2013 at 3:39 PM,  <lokeshkoppaka@gmail.com> wrote:
> On Saturday, May 25, 2013 10:54:01 AM UTC+5:30, Chris Angelico wrote:
>> On Sat, May 25, 2013 at 3:15 PM,  <lokeshkoppaka@gmail.com> wrote:
>>
>> > On Friday, May 24, 2013 1:34:51 PM UTC+5:30, lokesh...@gmail.com wrote:
>>
>> >> i need to write a code which can sort the list in order of 'n' without use builtin functions
>>
>> >>
>>
>> >> can anyone help me how to do?
>>
>> >
>>
>> >  Note:
>>
>> > the list only contains 0's,1's,2's
>>
>> > need to sort them in order of 'n'
>>
>>
>>
>> In that case, you're not really ordering them, you're counting them.
>>
>> Look at the collections module; you can very easily figure out how
>>
>> many of each there are, and then reconstruct the list afterward.
>>
>>
>>
>> ChrisA
>
> but i need to do it with out using builtin functions

Depending on your definitions, that's either trivially easy (the
'collections' module is not builtin functions) or completely
impossible. Have fun.

ChrisA

[toc] | [prev] | [next] | [standalone]


#45968

FromSteven D'Aprano <steve+comp.lang.python@pearwood.info>
Date2013-05-25 05:57 +0000
Message-ID<51a052d1$0$6599$c3e8da3$5496439d@news.astraweb.com>
In reply to#45964
On Fri, 24 May 2013 22:39:06 -0700, lokeshkoppaka wrote:

> On Saturday, May 25, 2013 10:54:01 AM UTC+5:30, Chris Angelico wrote:

>> In that case, you're not really ordering them, you're counting them.
>> Look at the collections module; you can very easily figure out how
>> many of each there are, and then reconstruct the list afterward.
> 
> but i need to do it with out using builtin functions


How would you, an intelligent human being count them?

Describe how you would count them in English, or whatever your native 
language is.

"First I would start a tally for the number of zeroes, tally = 0. Then I 
look at each item in turn, and if it is 0, I add one to the tally. When I 
get to the end, I the number of zeroes is equal to the tally.

Then I do the same for the number of ones, and the number of twos."

Now turn that into Python code. 

tally = 0
for item in list_of_items:
    if item == 0:
        tally = tally + 1

print "The number of zeroes equals", tally



-- 
Steven

[toc] | [prev] | [next] | [standalone]


#45970

Fromlokeshkoppaka@gmail.com
Date2013-05-24 23:05 -0700
Message-ID<74e33270-a79a-4878-a400-8a6cda6637b2@googlegroups.com>
In reply to#45968
On Saturday, May 25, 2013 11:27:38 AM UTC+5:30, Steven D'Aprano wrote:
> On Fri, 24 May 2013 22:39:06 -0700, lokeshkoppaka wrote:
> 
> 
> 
> > On Saturday, May 25, 2013 10:54:01 AM UTC+5:30, Chris Angelico wrote:
> 
> 
> 
> >> In that case, you're not really ordering them, you're counting them.
> 
> >> Look at the collections module; you can very easily figure out how
> 
> >> many of each there are, and then reconstruct the list afterward.
> 
> > 
> 
> > but i need to do it with out using builtin functions
> 
> 
> 
> 
> 
> How would you, an intelligent human being count them?
> 
> 
> 
> Describe how you would count them in English, or whatever your native 
> 
> language is.
> 
> 
> 
> "First I would start a tally for the number of zeroes, tally = 0. Then I 
> 
> look at each item in turn, and if it is 0, I add one to the tally. When I 
> 
> get to the end, I the number of zeroes is equal to the tally.
> 
> 
> 
> Then I do the same for the number of ones, and the number of twos."
> 
> 
> 
> Now turn that into Python code. 
> 
> 
> 
> tally = 0
> 
> for item in list_of_items:
> 
>     if item == 0:
> 
>         tally = tally + 1
> 
> 
> 
> print "The number of zeroes equals", tally
> 
> 
> 
> 
> 
> 
> 
> -- 
> 
> Steven

ya steven i had done the similar logic but thats not satisfying my professor 
he had given the following constrains
 1. No in-built functions should be used
 2. we are expecting a O(n) solution
 3. Don't use count method

[toc] | [prev] | [next] | [standalone]


#45971

FromChris Angelico <rosuav@gmail.com>
Date2013-05-25 16:12 +1000
Message-ID<mailman.2114.1369462347.3114.python-list@python.org>
In reply to#45970
On Sat, May 25, 2013 at 4:05 PM,  <lokeshkoppaka@gmail.com> wrote:
> ya steven i had done the similar logic but thats not satisfying my professor
> he had given the following constrains
>  1. No in-built functions should be used
>  2. we are expecting a O(n) solution
>  3. Don't use count method

And now you finally admit that it's homework.

Solve it yourself, or go to your prof and say that you need help.

ChrisA

[toc] | [prev] | [next] | [standalone]


#45974

FromCarlos Nepomuceno <carlosnepomuceno@outlook.com>
Date2013-05-25 10:53 +0300
Message-ID<mailman.2116.1369468467.3114.python-list@python.org>
In reply to#45970
----------------------------------------
> Date: Fri, 24 May 2013 23:05:17 -0700
> Subject: Re: help how to sort a list in order of 'n' in python without using inbuilt functions??
> From: lokeshkoppaka@gmail.com
> To: python-list@python.org
[...]
> ya steven i had done the similar logic but thats not satisfying my professor
> he had given the following constrains
> 1. No in-built functions should be used
> 2. we are expecting a O(n) solution
> 3. Don't use count method

That's trivial!

# l is a list of numbers: 0,1,2
def order_n(l):
    r = []
    count = [0]*3
    count[2] = len(l)
    for i in range(len(l)):
        count[1] += abs((l[i]>0)-1)
        r.insert(count[l[i]], l[i])
    return r

'count' is a list I've defined to count the quantity of the elements in the argument, not the method.

I don't think it needs any explanations, but if you have any doubts just ask. ;)

Good luck! 		 	   		  

[toc] | [prev] | [next] | [standalone]


#45976

FromChris Angelico <rosuav@gmail.com>
Date2013-05-25 18:28 +1000
Message-ID<mailman.2118.1369470514.3114.python-list@python.org>
In reply to#45970
On Sat, May 25, 2013 at 5:53 PM, Carlos Nepomuceno
<carlosnepomuceno@outlook.com> wrote:
> ----------------------------------------
>> Date: Fri, 24 May 2013 23:05:17 -0700
>> 1. No in-built functions should be used
>     count[2] = len(l)

Fail! :)

ChrisA

[toc] | [prev] | [next] | [standalone]


#45977

FromCarlos Nepomuceno <carlosnepomuceno@outlook.com>
Date2013-05-25 11:43 +0300
Message-ID<mailman.2120.1369471437.3114.python-list@python.org>
In reply to#45970
----------------------------------------
> Date: Sat, 25 May 2013 18:28:32 +1000
> Subject: Re: help how to sort a list in order of 'n' in python without using inbuilt functions??
> From: rosuav@gmail.com
> To: python-list@python.org
>
> On Sat, May 25, 2013 at 5:53 PM, Carlos Nepomuceno
> <carlosnepomuceno@outlook.com> wrote:
>> ----------------------------------------
>>> Date: Fri, 24 May 2013 23:05:17 -0700
>>> 1. No in-built functions should be used
>> count[2] = len(l)
>
> Fail! :)
>
> ChrisA
> --
> http://mail.python.org/mailman/listinfo/python-list

lol I forgot to include this monkey patch! ;)

def length(l):
    x=0
    y=l[:]
    while y:
        x+=1
        y.pop()
    return x 		 	   		  

[toc] | [prev] | [next] | [standalone]


#45978

FromChris Angelico <rosuav@gmail.com>
Date2013-05-25 18:47 +1000
Message-ID<mailman.2122.1369471652.3114.python-list@python.org>
In reply to#45970
On Sat, May 25, 2013 at 6:43 PM, Carlos Nepomuceno
<carlosnepomuceno@outlook.com> wrote:
> ----------------------------------------
> lol I forgot to include this monkey patch! ;)
>
> def length(l):
>     x=0
>     y=l[:]
>     while y:
>         x+=1
>         y.pop()
>     return x

Nice. Now eliminate abs (easy) and range. :)

ChrisA

[toc] | [prev] | [next] | [standalone]


#45979

FromCarlos Nepomuceno <carlosnepomuceno@outlook.com>
Date2013-05-25 11:54 +0300
Message-ID<mailman.2123.1369472102.3114.python-list@python.org>
In reply to#45970
lol

def absolute(x):
    return x if x>0 else -x

def reach(x):
    y=[]
    z=0
    while z<x:
        y.append(z)
        z+=1
    return y

----------------------------------------
> Date: Sat, 25 May 2013 18:47:24 +1000
> Subject: Re: help how to sort a list in order of 'n' in python without using inbuilt functions??
> From: rosuav@gmail.com
> To: python-list@python.org
>
> On Sat, May 25, 2013 at 6:43 PM, Carlos Nepomuceno
> <carlosnepomuceno@outlook.com> wrote:
>> ----------------------------------------
>> lol I forgot to include this monkey patch! ;)
>>
>> def length(l):
>> x=0
>> y=l[:]
>> while y:
>> x+=1
>> y.pop()
>> return x
>
> Nice. Now eliminate abs (easy) and range. :)
>
> ChrisA
> --
> http://mail.python.org/mailman/listinfo/python-list 		 	   		  

[toc] | [prev] | [next] | [standalone]


#45980

FromChris Angelico <rosuav@gmail.com>
Date2013-05-25 19:01 +1000
Message-ID<mailman.2124.1369472472.3114.python-list@python.org>
In reply to#45970
On Sat, May 25, 2013 at 6:54 PM, Carlos Nepomuceno
<carlosnepomuceno@outlook.com> wrote:
> lol
>
> def absolute(x):
>     return x if x>0 else -x
>
> def reach(x):
>     y=[]
>     z=0
>     while z<x:
>         y.append(z)
>         z+=1
>     return y

Very good. You are now in a position to get past the limitations of a
restricted-environment eval/exec. Avoiding builtins is actually a fun
skill to hone.

ChrisA

[toc] | [prev] | [next] | [standalone]


#45981

FromCarlos Nepomuceno <carlosnepomuceno@outlook.com>
Date2013-05-25 12:10 +0300
Message-ID<mailman.2126.1369473015.3114.python-list@python.org>
In reply to#45970
----------------------------------------
> Date: Sat, 25 May 2013 19:01:09 +1000
> Subject: Re: help how to sort a list in order of 'n' in python without using inbuilt functions??
> From: rosuav@gmail.com
> To: python-list@python.org
[...]
> Very good. You are now in a position to get past the limitations of a
> restricted-environment eval/exec. Avoiding builtins is actually a fun
> skill to hone.
>
> ChrisA


I'm glad he didn't ask for a Pseudo-RNG without built-ins! ;) 		 	   		  

[toc] | [prev] | [next] | [standalone]


#45982

FromChris Angelico <rosuav@gmail.com>
Date2013-05-25 19:14 +1000
Message-ID<mailman.2127.1369473306.3114.python-list@python.org>
In reply to#45970
On Sat, May 25, 2013 at 7:10 PM, Carlos Nepomuceno
<carlosnepomuceno@outlook.com> wrote:
> ----------------------------------------
>> Date: Sat, 25 May 2013 19:01:09 +1000
>> Subject: Re: help how to sort a list in order of 'n' in python without using inbuilt functions??
>> From: rosuav@gmail.com
>> To: python-list@python.org
> [...]
>> Very good. You are now in a position to get past the limitations of a
>> restricted-environment eval/exec. Avoiding builtins is actually a fun
>> skill to hone.
>>
>> ChrisA
>
>
> I'm glad he didn't ask for a Pseudo-RNG without built-ins! ;)

def random_number():
    return 7

ChrisA

[toc] | [prev] | [next] | [standalone]


#45994

FromSteven D'Aprano <steve+comp.lang.python@pearwood.info>
Date2013-05-25 14:28 +0000
Message-ID<51a0ca91$0$30002$c3e8da3$5496439d@news.astraweb.com>
In reply to#45982
On Sat, 25 May 2013 19:14:57 +1000, Chris Angelico wrote:

> def random_number():
>     return 7

I call shenanigans! That value isn't generated randomly, you just made it 
up! I rolled a die *hundreds* of times and not once did it come up seven!



-- 
Steven

[toc] | [prev] | [next] | [standalone]


Page 1 of 3  [1] 2 3  Next page →

Back to top | Article view | comp.lang.python


csiph-web