Path: csiph.com!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed2.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!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; 'subject:Open': 0.05; 'nested': 0.07; 'subject:Question': 0.07; 'cc:addr:python-list': 0.11; 'jan': 0.12; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'itertools': 0.16; 'notation': 0.16; 'subject: \n ': 0.16; 'subject:java': 0.16; 'subject:programming': 0.16; 'subject:python': 0.16; 'wrote:': 0.18; 'import': 0.22; 'cc:addr:python.org': 0.22; 'mon,': 0.24; 'cc:2**0': 0.24; 'this:': 0.26; 'header:In-Reply-To:1': 0.27; 'chris': 0.29; 'am,': 0.29; 'subject:please': 0.30; 'message-id:@mail.gmail.com': 0.30; '13,': 0.31; '>>>>': 0.31; 'subject:with': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'there': 0.35; 'really': 0.36; 'doing': 0.36; "didn't": 0.36; 'subject:?': 0.36; 'should': 0.36; 'little': 0.38; "couldn't": 0.39; 'how': 0.40; 'matter': 0.61; "you're": 0.61; 'more': 0.64; 'six': 0.68; 'repeat': 0.74; 'to:none': 0.92 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:cc :content-type; bh=JRlx3i+O1o9CJl+OBON5/R5LdSA+Jk2oZkL67NMCYlw=; b=wXzNkYsZlDOgzduP6pz8ilkfIzFs38Wly7jy+neTZRk1Yd9fAQeMseD85ETXDUI8Va N4LVIEsTVLAXBk/zp9XtPdt7RE3HtzzKQF1Lb+DlzXas8DcBHQqv7pnD1ueqlTcgeQDx EZdU59iiCM51IEwAnBudsah+rlb6Wb226qewJo4gipkdT1RM25Oj6pa+KgoIIPUctSuR zspOmhfV6LRTb9ee4GV7b/jA4yOaSTzlD3TdYdJQvlRBdZ0IsFERW6IvvG6DMD6nblLh XbygdYEVtMLIe43LeehFtvvAy96DERzexnrELD1bzQUaHk1rvSRI1CY/FJbsC+5Wwcuu Z/aw== MIME-Version: 1.0 X-Received: by 10.66.129.133 with SMTP id nw5mr24010419pab.98.1389537868821; Sun, 12 Jan 2014 06:44:28 -0800 (PST) In-Reply-To: References: <18b67e59-39d1-41e2-8977-b1c449b132e7@googlegroups.com> Date: Mon, 13 Jan 2014 01:44:28 +1100 Subject: Re: Open Question - I'm a complete novice in programming so please bear with me...Is python equivalent to C, C++ and java combined? From: Chris Angelico Cc: "python-list@python.org" Content-Type: text/plain; charset=UTF-8 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: 18 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1389537878 news.xs4all.nl 2936 [2001:888:2000:d::a6]:56161 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:63771 On Mon, Jan 13, 2014 at 1:36 AM, Rotwang wrote: > On 12/01/2014 05:58, Chris Angelico wrote: >> >> (BTW, is there no better notation than six nested for/range for doing >> 6d6? I couldn't think of one off-hand, but it didn't really much >> matter anyway.) > > > If you're willing to do an import, then how about this: > >>>> from itertools import product >>>> len([x for x in product(range(1, 7), repeat = 6) if sum(x) < 14])/6**6 > 0.03587962962962963 Should have known itertools would have something. That's a little more complicated to try to explain, but it's a lot shorter. ChrisA