Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #77016
| Path | csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.mixmin.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed2a.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <joel.goldstick@gmail.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.021 |
| X-Spam-Evidence | '*H*': 0.96; '*S*': 0.00; 'exercise': 0.04; 'tries': 0.07; 'happen.': 0.09; 'cc:addr:python-list': 0.11; 'def': 0.12; 'random': 0.14; '"your': 0.16; 'balls': 0.16; 'btw': 0.16; 'range(0,': 0.16; 'reedy': 0.16; 'simplest': 0.16; 'skip:> 20': 0.16; 'url:openbookproject': 0.16; 'width.': 0.16; 'wrote:': 0.18; 'trying': 0.19; '>>>': 0.22; 'import': 0.22; 'aug': 0.22; 'cc:addr:python.org': 0.22; 'print': 0.22; 'example.': 0.24; 'please?': 0.24; 'mon,': 0.24; 'cc:2**0': 0.24; 'header:In-Reply- To:1': 0.27; 'correct': 0.29; 'message-id:@mail.gmail.com': 0.30; 'url:mailman': 0.30; '25,': 0.31; '>>>>': 0.31; 'figure': 0.32; 'url:python': 0.33; '"the': 0.34; 'problem': 0.35; 'but': 0.35; 'received:google.com': 0.35; '+0200,': 0.36; 'skip:> 10': 0.36; 'url:listinfo': 0.36; 'url:org': 0.36; 'should': 0.36; 'list': 0.37; 'pm,': 0.38; 'mailing': 0.39; 'skip:p 20': 0.39; 'url:mail': 0.40; 'how': 0.40; 'up,': 0.60; 'numbers': 0.61; 'course': 0.61; 'first': 0.61; 'such': 0.63; 'more': 0.64; 'different': 0.65; 'containing': 0.69; 'repeat': 0.74; 'subject:This': 0.74; 'otten': 0.84; 'url:php': 0.85; 'joel': 0.91; 'numbers:': 0.91 |
| 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:to :cc:content-type; bh=zK+dQz6NRA0nUmI2bNr4NPQx/ff0TTJsCCPeUjwQi74=; b=kJVepw1UOBQMpVy3LAM0dOTqHDfiTg0rCIBdOBUPBrLWErBQ5n3EAbArOFDO3J5Rss wY3ldQpBo9qMc5V1FQ8K4xG8hWDwHIpvs6eyT/hpQTlkWCK9pHupQP38O3e59XKUwjhp C2tYwLs+rC4o59PnDWBkRq98mbRB8m+eBsjygy5sZtkkCJuNY8SQxBB+l2/KMmNIIrpD TvoZvCsGi+04zOHRUmQy5mgsXoTDgBZdjAsnwDXgtPPo57Al3+NrElKte4P8ds+hNvo2 02HX57Zx4GfPWpnzYKCJ5CAExfk+sR51Eq1qksDZdkzpPtKhnzYseLQaSyHSG1ugDC3i 8P4g== |
| MIME-Version | 1.0 |
| X-Received | by 10.194.191.165 with SMTP id gz5mr26339744wjc.16.1409015447973; Mon, 25 Aug 2014 18:10:47 -0700 (PDT) |
| In-Reply-To | <8imnv9l638q9hsvvib28t8qp0depa8rb7c@4ax.com> |
| References | <na5nv9l1slfkh4038ppc6779pbgajbbt19@4ax.com> <ltgcvd$b1c$1@ger.gmane.org> <mailman.13435.1409006947.18130.python-list@python.org> <8imnv9l638q9hsvvib28t8qp0depa8rb7c@4ax.com> |
| Date | Mon, 25 Aug 2014 21:10:47 -0400 |
| Subject | Re: This formating is really tricky |
| From | Joel Goldstick <joel.goldstick@gmail.com> |
| To | Seymore4Head <Seymore4Head@hotmail.invalid> |
| Content-Type | text/plain; charset=UTF-8 |
| Cc | "python-list@python.org" <python-list@python.org> |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.15 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list/> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.13438.1409015454.18130.python-list@python.org> (permalink) |
| Lines | 62 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1409015454 news.xs4all.nl 2829 [2001:888:2000:d::a6]:34628 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:77016 |
Show key headers only | View raw
you should try python-tudor mailing list
On Mon, Aug 25, 2014 at 8:52 PM, Seymore4Head
<Seymore4Head@hotmail.invalid> wrote:
> On Tue, 26 Aug 2014 00:48:52 +0200, Peter Otten <__peter__@web.de>
> wrote:
>
>>Terry Reedy wrote:
>>
>>> On 8/25/2014 4:14 PM, Seymore4Head wrote:
>>>> import random
>>>> sets=3
>>>> for x in range(0, sets):
>>>> pb2=random.choice([1-53])
>>>
>>> You want random.randint(1, 53)
>>> ...
>>>> alist = sorted([pb1, pb2, pb3, pb4, pb5])
>>>> print ("Your numbers: {} Powerball: {}".format(alist, pb6))
>>>>
>>>> I am trying this example. The program works, but the numbers don't
>>>> line up if the number of digits are different sizes.
>>>> http://openbookproject.net/pybiblio/practice/wilson/powerball.php
>>>
>>> To get them to line up, you have to format each one to the same width.
>>>
>>>> Suggestion please?
>>>> BTW the exercise instructions say to use the choice function.
>>>
>>> import random
>>> sets=3
>>>
>>> def ran53():
>>> return random.randint(1, 53)
>>>
>>> f1 = '{:2d}'
>>> bform = "Your numbers: [{0}, {0}, {0}, {0}, {0}]".format(f1)
>>> pform = " Powerball: {0}".format(f1)
>>>
>>> for x in range(0, sets):
>>> balls = sorted(ran53() for i in range(5))
>>
>>Quoting the problem description: "The first five numbers are drawn from a
>>drum containing 53 balls"
>>
>>Thus no number should repeat in the first five. With your approach such
>>repetitions can happen. The simplest solution is of course
>>
>>random.sample(range(1, 54), 5)
>>
>>but the OP will learn more when he tries to figure out how to get a correct
>>solution with choice().
>>
> Don't bet on it. :)
> --
> https://mail.python.org/mailman/listinfo/python-list
--
Joel Goldstick
http://joelgoldstick.com
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
This formating is really tricky Seymore4Head <Seymore4Head@Hotmail.invalid> - 2014-08-25 16:14 -0400
Re: This formating is really tricky Mark Lawrence <breamoreboy@yahoo.co.uk> - 2014-08-25 21:52 +0100
Re: This formating is really tricky Seymore4Head <Seymore4Head@Hotmail.invalid> - 2014-08-25 23:12 -0400
Re: This formating is really tricky Rustom Mody <rustompmody@gmail.com> - 2014-08-25 14:05 -0700
Re: This formating is really tricky Seymore4Head <Seymore4Head@Hotmail.invalid> - 2014-08-25 23:14 -0400
Re: This formating is really tricky Larry Hudson <orgnut@yahoo.com> - 2014-08-26 23:46 -0700
Re: This formating is really tricky Seymore4Head <Seymore4Head@Hotmail.invalid> - 2014-08-27 09:36 -0400
Re: This formating is really tricky Terry Reedy <tjreedy@udel.edu> - 2014-08-25 18:22 -0400
Re: This formating is really tricky Seymore4Head <Seymore4Head@Hotmail.invalid> - 2014-08-25 20:51 -0400
Re: This formating is really tricky Seymore4Head <Seymore4Head@Hotmail.invalid> - 2014-08-25 21:16 -0400
Re: This formating is really tricky Seymore4Head <Seymore4Head@Hotmail.invalid> - 2014-08-26 15:31 -0400
Re: This formating is really tricky Peter Otten <__peter__@web.de> - 2014-08-27 09:16 +0200
Re: This formating is really tricky Seymore4Head <Seymore4Head@Hotmail.invalid> - 2014-08-27 09:35 -0400
Re: This formating is really tricky Peter Otten <__peter__@web.de> - 2014-08-26 00:48 +0200
Re: This formating is really tricky Seymore4Head <Seymore4Head@Hotmail.invalid> - 2014-08-25 20:52 -0400
Re: This formating is really tricky Joel Goldstick <joel.goldstick@gmail.com> - 2014-08-25 21:10 -0400
Re: This formating is really tricky Gregory Ewing <greg.ewing@canterbury.ac.nz> - 2014-08-26 18:17 +1200
Re: This formating is really tricky Chris Angelico <rosuav@gmail.com> - 2014-08-26 16:22 +1000
Re: This formating is really tricky alister <alister.nospam.ware@ntlworld.com> - 2014-08-26 09:27 +0000
Re: This formating is really tricky Marko Rauhamaa <marko@pacujo.net> - 2014-08-26 12:32 +0300
Re: This formating is really tricky alister <alister.nospam.ware@ntlworld.com> - 2014-08-26 10:32 +0000
Re: This formating is really tricky Mark Lawrence <breamoreboy@yahoo.co.uk> - 2014-08-26 06:57 +0100
Re: This formating is really tricky MRAB <python@mrabarnett.plus.com> - 2014-08-26 12:24 +0100
Re: This formating is really tricky Joel Goldstick <joel.goldstick@gmail.com> - 2014-08-26 09:28 -0400
Re: This formating is really tricky Mark Lawrence <breamoreboy@yahoo.co.uk> - 2014-08-26 17:09 +0100
Re: This formating is really tricky Chris Angelico <rosuav@gmail.com> - 2014-08-27 02:13 +1000
Re: This formating is really tricky Peter Otten <__peter__@web.de> - 2014-08-26 18:28 +0200
Re: This formating is really tricky Chris Angelico <rosuav@gmail.com> - 2014-08-27 02:33 +1000
Re: This formating is really tricky Mark Lawrence <breamoreboy@yahoo.co.uk> - 2014-08-26 18:19 +0100
Re: This formating is really tricky Gregory Ewing <greg.ewing@canterbury.ac.nz> - 2014-08-27 09:39 +1200
Re: This formating is really tricky Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-08-26 12:45 +1000
Re: This formating is really tricky Seymore4Head <Seymore4Head@Hotmail.invalid> - 2014-08-25 23:10 -0400
Re: This formating is really tricky Gene Heskett <gheskett@wdtv.com> - 2014-08-26 14:50 -0400
csiph-web