Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed3a.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.003 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; '"this': 0.03; 'else:': 0.03; 'syntax': 0.04; 'logic': 0.09; 'cc:addr:python-list': 0.11; 'python': 0.11; 'itself.': 0.14; 'books': 0.15; 'cc:name:python list': 0.16; 'count,': 0.16; 'excludes': 0.16; 'itself).': 0.16; 'requested.': 0.16; 'true:': 0.16; 'wrote:': 0.18; '(not': 0.18; 'library': 0.18; '(the': 0.22; 'input': 0.22; 'cc:addr:python.org': 0.22; 'print': 0.22; '(a)': 0.24; "haven't": 0.24; 'cc:2**0': 0.24; '>': 0.26; 'header:In-Reply-To:1': 0.27; 'message-id:@mail.gmail.com': 0.30; "i'm": 0.30; 'url:mailman': 0.30; 'code': 0.31; 'default,': 0.31; 'factor': 0.31; 'sep': 0.31; 'url:python': 0.33; 'but': 0.35; 'received:google.com': 0.35; 'url:listinfo': 0.36; 'doing': 0.36; 'url:org': 0.36; 'skip:& 10': 0.38; 'pm,': 0.38; 'skip:& 20': 0.39; 'heard': 0.39; 'url:mail': 0.40; 'how': 0.40; 'problems.': 0.60; 'then,': 0.60; 'break': 0.61; '8bit%:100': 0.72; 'prime': 0.74; 'divide': 0.84; 'url:2014': 0.84; 'url:16': 0.93 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=jNdrlIJ/iVmB6c3vuQlPxUwqzceGSq7c26Aej8ftnyI=; b=eLDiaBpJ2j2N2p0q09Iy9h8q4ma6/DlCu8PxM6ULipES7JqX8fnrB6+yZbD2O9eyE1 BsXb9iXuXv9W1oCOOH70WLdfbPv/4zKJEILqQuVxja3Dsuke4dFZPio+mmUbzQoBvJ09 ov44GmSyzKZsmXhtK9YIL/ApII7NYunZBX57r8eXq4Atx7kMHhhCvBBLtTEeyk60XCBj OPkg8nhD1esqbUTyDuyAtcI6nhDeL2tYfG57CQay88wtEvENEC4BHdmxLj9A1NumxRsy m5zz00yRE33hIQ6CjiogKnGaR67Z2kEJQZtKUGumruUHt1nR5WfLAoRxZ5K8HadBikCM klog== MIME-Version: 1.0 X-Received: by 10.50.39.8 with SMTP id l8mr6716889igk.13.1409936670722; Fri, 05 Sep 2014 10:04:30 -0700 (PDT) In-Reply-To: <1enj0att6bkrnvb81rhma5dbuk3h28agl8@4ax.com> References: <1enj0att6bkrnvb81rhma5dbuk3h28agl8@4ax.com> Date: Fri, 5 Sep 2014 13:04:30 -0400 Subject: Re: My backwards logic From: Bob Gailer To: Seymore4Head Content-Type: multipart/alternative; boundary=047d7bdc153e6a514e0502547679 Cc: python 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: 92 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1409936673 news.xs4all.nl 2911 [2001:888:2000:d::a6]:33220 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:77593 --047d7bdc153e6a514e0502547679 Content-Type: text/plain; charset=UTF-8 Bob gailer On Sep 5, 2014 12:51 PM, "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 else: print ... > 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" > > -- > https://mail.python.org/mailman/listinfo/python-list --047d7bdc153e6a514e0502547679 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable

Bob gailer
On Sep 5, 2014 12:51 PM, "Seymore4Head" <Seymore4Head@hotmail.= invalid> wrote:
>
> I'm still doing practice problems.=C2=A0 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.=C2=A0 = A
> prime number will divide by one and itself.=C2=A0 When setting up this=
> loop, if I start at 2 instead of 1, that automatically excludes one of=
> the factors.=C2=A0 Then, by default, Python goes "to" the ch= osen 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:
> =C2=A0 =C2=A0 a=3Drandom.randrange(1,8)
> =C2=A0 =C2=A0 print (a)
> =C2=A0 =C2=A0 for x in range(2,a):
> =C2=A0 =C2=A0 =C2=A0 =C2=A0 if a%x=3D=3D0:
> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 print ("Number is not p= rime")
> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 break
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 else:
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 print ...
> =C2=A0 =C2=A0 wait =3D input (" "*40=C2=A0 + "Wait"= ;)
>
> But, what this instructions want printed is "This is a prime numb= er"
> So how to I use this code logic NOT print (not prime) and have the
> logic print "This number is prime"
>
> --
> https= ://mail.python.org/mailman/listinfo/python-list

--047d7bdc153e6a514e0502547679--