Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #67399

Re: Help with "Guess the number" script

Path csiph.com!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!newsfeed.xs4all.nl!newsfeed4.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <swdunning@cox.net>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.002
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'else:': 0.03; 'yet.': 0.04; 'elif': 0.05; 'variables': 0.07; 'subject:number': 0.09; 'subject:script': 0.09; 'cc:addr:python-list': 0.11; 'subject:Help': 0.11; 'def': 0.12; 'wrote': 0.14; 'random': 0.14; 'bit.': 0.16; 'count,': 0.16; 'loops': 0.16; 'wrote:': 0.18; '(not': 0.18; 'received:10.0.1': 0.19; 'import': 0.22; 'cc:addr:python.org': 0.22; 'cc:2**0': 0.24; 'cc:no real name:2**0': 0.24; 'header:In-Reply-To:1': 0.27; 'function': 0.29; 'am,': 0.29; 'guess': 0.33; 'sense': 0.34; 'subject:the': 0.34; 'problem': 0.35; 'subject:with': 0.35; 'false': 0.36; 'thanks': 0.36; 'received:10.0': 0.36; 'should': 0.36; 'received:10': 0.37; 'subject:" ': 0.39; 'header:Message-Id:1': 0.63; 'to:addr:gmail.com': 0.65; 'charset:windows-1252': 0.65; 'between': 0.67; 'mar': 0.68; '2014,': 0.84; 'haven\x92t': 0.84; 'he\x92s': 0.84
X-CT-Class Clean
X-CT-Score 0.00
X-CT-RefID str=0001.0A020205.5312852D.002F,ss=1,re=0.000,fgs=0
X-CT-Spam 0
X-Authority-Analysis v=2.0 cv=F4SJgNdN c=1 sm=1 a=MB85R812cvcrhCHz/P2OVA==:17 a=gK21Zm9gRZcA:10 a=G8Uczd0VNMoA:10 a=N659UExz7-8A:10 a=kviXuzpPAAAA:8 a=pGLkceISAAAA:8 a=J9HLMndYH5Ab8L0EqCYA:9 a=pILNOxqGKmIA:10 a=MSl-tDqOz04A:10 a=QwvQD4F-AEqmwTl7:21 a=GPZRD02DKTtY7scO:21 a=MB85R812cvcrhCHz/P2OVA==:117
X-CM-Score 0.00
Authentication-Results cox.net; auth=pass (PLAIN) smtp.auth=swdunning@cox.net
Content-Type text/plain; charset=windows-1252
Mime-Version 1.0 (Mac OS X Mail 7.1 \(1827\))
Subject Re: Help with "Guess the number" script
From Scott W Dunning <swdunning@cox.net>
In-Reply-To <YJ7s1n00C3bjUJS01J7tQ2>
Date Sat, 1 Mar 2014 18:11:07 -0700
Content-Transfer-Encoding quoted-printable
References <43B63C46-3A2D-4374-8A42-EE931BA9A6C4@cox.net> <mailman.7516.1393691734.18130.python-list@python.org> <YJ7s1n00C3bjUJS01J7tQ2>
To Susan Aldridge <susanaldridge555@gmail.com>
X-Mailer Apple Mail (2.1827)
Cc 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.7555.1393722671.18130.python-list@python.org> (permalink)
Lines 29
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1393722671 news.xs4all.nl 2829 [2001:888:2000:d::a6]:48266
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:67399

Show key headers only | View raw


On Mar 1, 2014, at 11:03 AM, Susan Aldridge <susanaldridge555@gmail.com> wrote:
> Try this
> 
> def guess1(upLimit = 100):
>    import random
>    num = random.randint(1,upLimit)
>    count = 0
>    gotIt = False
>    while (not gotIt):
>        print('Guess a number between 1 and', upLimit, ':')
>        guess= int(input())
>        count += 1
>        if guess == num:
>              print('Congrats! You win')
>              gotIt = True
>        elif guess < num:
>              print('Go up!')
>        else:
>              print('Guess less')
>    print('You got it in ', count, 'guesses.')
> 
> guess1(100)
Thanks Susan!  The only problem is he wants us to do it without loops because we haven’t learned them yet. I need to use the variables and function names that he’s given as well.  I think I can make sense of what you wrote though so that should help me a bit.  

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Re: Help with "Guess the number" script Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2014-03-01 11:35 -0500
  Re: Help with "Guess the number" script Susan Aldridge <susanaldridge555@gmail.com> - 2014-03-01 10:03 -0800
  Re: Help with "Guess the number" script Scott W Dunning <swdunning@cox.net> - 2014-03-01 18:11 -0700
    Re: Help with "Guess the number" script Larry Hudson <orgnut@yahoo.com> - 2014-03-01 23:38 -0800
    Re: Help with "Guess the number" script Scott W Dunning <swdunning@cox.net> - 2014-03-02 18:36 -0700
  Re: Help with "Guess the number" script Chris Angelico <rosuav@gmail.com> - 2014-03-02 12:16 +1100
  Re: Help with "Guess the number" script Scott W Dunning <swdunning@cox.net> - 2014-03-02 18:40 -0700
  Re: Help with "Guess the number" script Scott W Dunning <swdunning@cox.net> - 2014-03-02 20:44 -0700
  Re: Help with "Guess the number" script Ben Finney <ben+python@benfinney.id.au> - 2014-03-03 14:52 +1100
  Re: Help with "Guess the number" script Scott W Dunning <swdunning@cox.net> - 2014-03-02 21:04 -0700
  Re: Help with "Guess the number" script Dave Angel <davea@davea.name> - 2014-03-03 02:10 -0500

csiph-web