Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #65224
| Path | csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!goblin1!goblin2!goblin.stu.neva.ru!newsfeed.xs4all.nl!newsfeed1.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <larry.martell@gmail.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.000 |
| X-Spam-Evidence | '*H*': 1.00; '*S*': 0.00; 'else:': 0.03; 'elif': 0.05; 'output': 0.05; 'subject:Python': 0.06; 'assignment': 0.07; 'column': 0.07; 'suppress': 0.09; 'cc:addr:python-list': 0.11; 'python': 0.11; 'def': 0.12; 'columns': 0.16; 'comma': 0.16; 'compute': 0.16; 'formatted': 0.16; 'true:': 0.16; 'wrote:': 0.18; '<': 0.19; 'pfxlen:0': 0.19; 'properly': 0.19; 'programming': 0.22; 'email addr:gmail.com>': 0.22; 'cc:addr:python.org': 0.22; 'print': 0.22; 'cc:2**0': 0.24; '>': 0.26; 'header:In- Reply-To:1': 0.27; 'statement': 0.30; 'message- id:@mail.gmail.com': 0.30; "i'm": 0.30; 'code': 0.31; 'aligned': 0.31; 'subject:numbers': 0.31; 'but': 0.35; 'received:google.com': 0.35; 'complete.': 0.36; 'false': 0.36; 'skip:p 20': 0.39; 'how': 0.40; 'break': 0.61; 'new': 0.61; 'numbers': 0.61; 'first': 0.61; 'to:addr:gmail.com': 0.65; 'prime': 0.74; '2014,': 0.84 |
| 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=TMCRRa46qW7v/Mmmb07gGkJery8d8o7rJWP4cmLuDoo=; b=SqJ8fyhj5XLnEJTeLc7/oEuPf1P02vsjDzdjzyUm5JLy6fbESDuK9wIpVShJcej57/ HpesDrC23gZOlNk89qe+5Oj1mjYRvxLkV8hLdz99G52Xc1BvwvtwjpDX6/iY3F0caxj9 bfdj4cO3WnvnEISorRUTLZOXA/0V8qKl9UvqG2HOzaP+XCrheXCU1C5SbGz/klp+FrFD TgEox7g1HFMhlRJ2F9vS9NA6QcvLKkyG+XhNcKBEc3zTrbh5t2zkJyNOSYuiCoNXSE+k 3+qkp8Y9AEa9C7hieJ60D/hd9zZJcV4eScZL7+a8XOOQninEfbdbkA1YxlSlsjdVT4vy NJbQ== |
| MIME-Version | 1.0 |
| X-Received | by 10.140.50.131 with SMTP id s3mr4166376qga.12.1391269853110; Sat, 01 Feb 2014 07:50:53 -0800 (PST) |
| In-Reply-To | <158634a8-3c20-4e04-bc2a-a562c7270a3b@googlegroups.com> |
| References | <158634a8-3c20-4e04-bc2a-a562c7270a3b@googlegroups.com> |
| Date | Sat, 1 Feb 2014 10:50:53 -0500 |
| Subject | Re: Python prime numbers |
| From | Larry Martell <larry.martell@gmail.com> |
| To | Panagiotis Anastasiou <panast24@gmail.com> |
| Content-Type | multipart/alternative; boundary=001a1135229661a66604f15a41df |
| 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.6283.1391269855.18130.python-list@python.org> (permalink) |
| Lines | 95 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1391269855 news.xs4all.nl 2963 [2001:888:2000:d::a6]:41796 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:65224 |
Show key headers only | View raw
[Multipart message — attachments visible in raw view] - view raw
On Saturday, February 1, 2014, Panagiotis Anastasiou <panast24@gmail.com>
wrote:
> Hi i'm new in programming and in python and i have an assignment that i
> cant complete. I have to Write a Python program to compute and print the
> first 200 prime numbers. The output must be formatted with a title and the
> prime numbers must be printed in 5 properly aligned columns . I have used
> this code so far :
>
> numprimes = raw_input('Prime Numbers ')
> count = 0
> potentialprime = 2
>
> def primetest(potentialprime):
> divisor = 2
> while divisor <= potentialprime:
> if potentialprime == 2:
> return True
> elif potentialprime % divisor == 0:
> return False
> break
> while potentialprime % divisor != 0:
> if potentialprime - divisor > 1:
> divisor += 1
> else:
> return True
>
> while count < int(numprimes):
> if primetest(potentialprime) == True:
> print potentialprime
> count += 1
> potentialprime += 1
> else:
> potentialprime += 1
>
> but i get the result in a single column . How can i get it in 5 rows? Can
> someone help please
>
If you put a comma at the end of the print statement it will suppress the
newline.
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Python prime numbers Panagiotis Anastasiou <panast24@gmail.com> - 2014-02-01 07:33 -0800 Re: Python prime numbers Larry Martell <larry.martell@gmail.com> - 2014-02-01 10:50 -0500 Re:Python prime numbers Dave Angel <davea@davea.name> - 2014-02-01 16:59 -0500 Re:Python prime numbers Dave Angel <davea@davea.name> - 2014-02-01 17:07 -0500 Re: Python prime numbers Wiktor <look@signature.invalid> - 2014-02-02 00:34 +0100
csiph-web