Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!us.feeder.erje.net!137.226.231.214.MISMATCH!newsfeed.fsmpi.rwth-aachen.de!nuzba.szn.dk!pnx.dk!news.stack.nl!newsfeed.xs4all.nl!newsfeed3.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.007 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'float': 0.05; 'subject:How': 0.09; '[0,': 0.09; 'subject:create': 0.09; 'cc:addr :python-list': 0.10; 'subject:python': 0.11; '100,': 0.16; 'subject:array': 0.16; 'subject:random': 0.16; 'code.': 0.20; 'cheers,': 0.23; 'cc:2**0': 0.23; 'work.': 0.23; 'random': 0.24; 'tried': 0.25; 'cc:addr:python.org': 0.25; 'header:In-Reply-To:1': 0.25; 'skip:[ 10': 0.26; 'values': 0.26; 'message- id:@mail.gmail.com': 0.27; 'url:mailman': 0.29; 'array': 0.29; 'url:python': 0.32; 'url:listinfo': 0.32; 'received:google.com': 0.34; 'but': 0.36; 'url:org': 0.36; 'does': 0.37; 'subject:: ': 0.38; 'url:mail': 0.40; 'range': 0.60; 'more': 0.63; 'boris': 0.84; 'ranging': 0.91 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:mime-version:in-reply-to:references:from:date:message-id :subject:to:cc:content-type; bh=ci0245WJj2E5PPGo/CAODdELuv0TQ5tLdH8Y/W3dTbs=; b=Vs2ukhtQZfvR9mcVb/+3ZTk7wCeHVeeIg3C0hWcGzQW2wnaVS5J+DpKBaLSCTQ0srN v5je0vluY0PkohCcZ9yjUIEhwDVsKbskpOITYmih6hwHE+L4TCSvvvJS3iXp/zZCbUZB f8EQpaxuf+6prA2uLd4OHoxy62blBzYTsJoD9IK0cUvnDlFYj9oIdwk8GvaTu19kzbeP E7Y5XKnSAqjVqNVE3hPIKci1d33HGbzPS7QMGd/LHuOJYNDKl040hP6pIEkT7eN0wFd2 DLONK22ktW0e6Ww5SEWYrko/377WVHqjBnMJPUkRHZ54YG0AgQYy33RWPqnBzAObH2lc Nr3g== X-Received: by 10.221.7.7 with SMTP id om7mr2731856vcb.29.1363109157883; Tue, 12 Mar 2013 10:25:57 -0700 (PDT) MIME-Version: 1.0 In-Reply-To: References: From: Boris FELD Date: Tue, 12 Mar 2013 18:25:36 +0100 Subject: Re: How can i create a random array of floats from 0 to 5 in python To: Norah Jones Content-Type: text/plain; charset=UTF-8 Cc: Python mailing list 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: 13 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1363109169 news.xs4all.nl 6962 [2001:888:2000:d::a6]:55655 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:41136 You can use [random.random() * 5 for x in range(100)] but works only on range [0, 5). If you want to include 5, you will need more code. Cheers, FELD Boris 2013/3/12 Norah Jones : > I want to create a random float array of size 100, with the values in the > array ranging from 0 to 5. I have tried random.sample(range(5),100) but that > does not work. How can i get what i want to achieve? > -- > http://mail.python.org/mailman/listinfo/python-list >