Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.albasani.net!news.stack.nl!newsfeed.xs4all.nl!newsfeed2a.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.003 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; '"this': 0.03; 'syntax': 0.04; 'logic': 0.09; 'python': 0.11; 'itself.': 0.14; 'books': 0.15; 'count,': 0.16; 'excludes': 0.16; 'from:addr:mrabarnett.plus.com': 0.16; 'from:addr:python': 0.16; 'from:name:mrab': 0.16; 'itself).': 0.16; 'message- id:@mrabarnett.plus.com': 0.16; 'received:192.168.1.4': 0.16; 'requested.': 0.16; 'true:': 0.16; 'wrote:': 0.18; '(not': 0.18; 'library': 0.18; '(the': 0.22; 'input': 0.22; 'print': 0.22; 'header:User-Agent:1': 0.23; '(a)': 0.24; "haven't": 0.24; 'header :In-Reply-To:1': 0.27; "i'm": 0.30; 'code': 0.31; 'default,': 0.31; 'factor': 0.31; 'one,': 0.35; 'but': 0.35; 'doing': 0.36; 'url:org': 0.36; 'to:addr:python-list': 0.38; 'heard': 0.39; 'to:addr:python.org': 0.39; 'how': 0.40; 'problems.': 0.60; 'then,': 0.60; 'break': 0.61; 'prime': 0.74; 'divide': 0.84; 'url:2014': 0.84; 'url:16': 0.93 X-CM-Score: 0.00 X-CNFS-Analysis: v=2.1 cv=Uv7tNoAB c=1 sm=1 tr=0 a=0nF1XD0wxitMEM03M9B4ZQ==:117 a=0nF1XD0wxitMEM03M9B4ZQ==:17 a=0Bzu9jTXAAAA:8 a=u9EReRu7m0cA:10 a=ud-rJsx2cw0A:10 a=ihvODaAuJD4A:10 a=IkcTkHD0fZMA:10 a=EBOSESyhAAAA:8 a=2owfo9IyAAAA:8 a=HvBQI5Na2YfIDGEbZVgA:9 a=8ocJVIk7nr14FWNN:21 a=rLSx30UdAETynG91:21 a=QEXdDO2ut3YA:10 a=2vFqvlW0kQAA:10 X-AUTH: mrabarnett:2500 Date: Fri, 05 Sep 2014 17:57:56 +0100 From: MRAB User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64; rv:24.0) Gecko/20100101 Thunderbird/24.6.0 MIME-Version: 1.0 To: python-list@python.org Subject: Re: My backwards logic References: <1enj0att6bkrnvb81rhma5dbuk3h28agl8@4ax.com> In-Reply-To: <1enj0att6bkrnvb81rhma5dbuk3h28agl8@4ax.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit 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: 28 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1409936285 news.xs4all.nl 2885 [2001:888:2000:d::a6]:57707 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:77591 On 2014-09-05 17:48, Seymore4Head wrote: > I'm still doing practice problems. I haven't heard from the library > on any of the books I have requested. > > http://www.practicepython.org/exercise/2014/04/16/11-check-primality-functions.html > > This is not a hard problem, but it got me to thinking a little. A > prime number will divide by one and itself. When setting up this > loop, if I start at 2 instead of 1, that automatically excludes one of > the factors. Then, by default, Python goes "to" the chosen count and > not "through" the count, so just the syntax causes Python to rule out > the other factor (the number itself). > > So this works: > while True: > a=random.randrange(1,8) > print (a) > for x in range(2,a): > if a%x==0: > print ("Number is not prime") > break > wait = input (" "*40 + "Wait") > > But, what this instructions want printed is "This is a prime number" > So how to I use this code logic NOT print (not prime) and have the > logic print "This number is prime" > Look for a factor. If you don't find one, it's a prime number.