Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed1a.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.008 X-Spam-Evidence: '*H*': 0.98; '*S*': 0.00; 'interpreter': 0.05; 'scipy': 0.05; 'great.': 0.07; 'beginners': 0.09; 'literal': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'subject:number': 0.09; 'sure,': 0.09; 'stored': 0.12; 'translation': 0.12; 'chained': 0.16; 'combined.': 0.16; 'it;': 0.16; 'list"': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'roy': 0.16; 'component': 0.16; 'appropriate': 0.16; 'student': 0.16; 'wrote:': 0.18; 'pieces': 0.19; 'code,': 0.22; 'print': 0.22; 'creating': 0.23; 'header :User-Agent:1': 0.23; 'together.': 0.24; '(or': 0.24; 'sort': 0.25; 'supported': 0.26; 'header:X-Complaints-To:1': 0.27; 'header :In-Reply-To:1': 0.27; 'specifically': 0.29; 'operations,': 0.30; 'subject:list': 0.30; 'largest': 0.30; 'code': 0.31; 'easier': 0.31; 'that.': 0.31; 'too.': 0.31; 'breaking': 0.31; 'idea,': 0.31; 'research.': 0.31; 'another': 0.32; 'running': 0.33; 'becomes': 0.33; 'actual': 0.34; 'subject:the': 0.34; 'knowledge': 0.35; 'connection': 0.35; 'point.': 0.35; 'but': 0.35; 'really': 0.36; 'bought': 0.36; 'shows': 0.36; 'url:amazon': 0.38; 'skip:[ 10': 0.38; 'to:addr:python-list': 0.38; 'list,': 0.38; 'pm,': 0.38; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'how': 0.40; 'break': 0.61; 'helps': 0.61; 'numbers': 0.61; 'teaching': 0.64; 'teach': 0.65; 'temporary': 0.65; 'close': 0.67; 'production': 0.68; 'combining': 0.68; 'smith': 0.68; 'article': 0.77; 'subject:get': 0.81; 'clearer': 0.84; 'obvious.': 0.84; 'benefits:': 0.91; 'do:': 0.91; 'talk,': 0.91; 'examine': 0.93; 'technique': 0.93; 'taught': 0.96 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: "Neil D. Cerutti" Subject: Re: how to get the ordinal number in list Date: Tue, 12 Aug 2014 13:40:48 -0400 References: <53E658CD.5020904@gmail.com> <53e59035$0$29998$c3e8da3$5496439d@news.astraweb.com> <338e8fb0-c9ec-462a-b560-1c1ff77de17e@googlegroups.com> <154cc342-7f85-4d16-b636-a1a953913c98@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Gmane-NNTP-Posting-Host: jackman.norwich.edu User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:24.0) Gecko/20100101 Thunderbird/24.6.0 In-Reply-To: X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 59 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1407865263 news.xs4all.nl 2834 [2001:888:2000:d::a6]:38008 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:76125 On 8/10/2014 2:14 PM, Roy Smith wrote: > In article <154cc342-7f85-4d16-b636-a1a953913c98@googlegroups.com>, > Rustom Mody wrote: > >>>>> l= [6,2,9,12,1,4] >>>>> sorted(l,reverse=True)[:5] >> [12, 9, 6, 4, 2] >> >> No need to know how sorted works nor [:5] >> >> Now you (or Steven) can call it abstract. >> >> And yet its >> 1. Actual running code in the interpreter >> 2. Its as close as one can get to a literal translation of your >> "Find the 5 largest numbers in a list" >> [...] >> All the above are clearer than loops+assignments and can be >> taught before them > > I disagree. For a beginner, you want to be able to break things down > into individual steps and examine the result at each point. If you do: > >>>>> l= [6,2,9,12,1,4] >>>>> l2 = sorted(l,reverse=True) > > you have the advantage that you can stop after creating l2 and print it > out. The student can see that it has indeed been sorted. With the > chained operations, you have to build a mental image of an anonymous, > temporary list, and then perform the slicing operation on that. Sure, > it's the way you or I would write it in production code, but for a > beginner, breaking it down into smaller pieces makes it easier to > understand. > >>>>> l2[:5] Yes, and that teaching technique is supported by research. Beginners are particularly poor, in relation to experts, at noticing the applicability of idea, and at combining ideas together. Breaking things into component parts has multiple benefits: 1. The applicability of individual ideas becomes obvious. It's one thing to know about [].sort, and another thing to know when it's appropriate to sort something. 2. The expert specifically shows how and why the ideas are combined. This helps build the connection for the beginner, whose knowledge is not stored as an expert stores it; i.e, in broad categories with multiple connections; but as disorganized data with very few connections. http://www.amazon.com/How-Learning-Works-Research-Based-Principles/dp/0470484101 I bought the book based on a recommendation from SciPy talk, and it's really great. As an autodidact, it'll help me teach *myself* better, too. -- Neil Cerutti