Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!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.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; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'python': 0.11; 'def': 0.12; 'wrote': 0.14; 'columns': 0.16; 'compute': 0.16; 'formatted': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'true:': 0.16; 'properly': 0.19; 'programming': 0.22; 'print': 0.22; 'header:X-Complaints-To:1': 0.27; "i'm": 0.30; 'code': 0.31; 'aligned': 0.31; 'subject:numbers': 0.31; 'but': 0.35; 'complete.': 0.36; 'false': 0.36; 'to:addr:python-list': 0.38; 'to:addr:python.org': 0.39; 'skip:p 20': 0.39; 'received:org': 0.40; 'how': 0.40; 'break': 0.61; 'new': 0.61; 'numbers': 0.61; 'first': 0.61; 'prime': 0.74; 'subject::': 0.85 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Dave Angel Subject: Re:Python prime numbers Date: Sat, 1 Feb 2014 16:59:43 -0500 (EST) Organization: news.gmane.org References: <158634a8-3c20-4e04-bc2a-a562c7270a3b@googlegroups.com> X-Gmane-NNTP-Posting-Host: dpc6744192077.direcpc.com X-Newsreader: PiaoHong Usenet NewsReaders 1.36 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: 36 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1391291803 news.xs4all.nl 2948 [2001:888:2000:d::a6]:54856 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:65239 Panagiotis Anastasiou Wrote in message: > 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 > -- DaveA