why are printing the string using three quotes? I know three means a doc string... just not sure. <div><br></div><div><p class="MsoNormal" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; border-collapse: collapse; font-family: arial, sans-serif; font-size: 13px; ">
if guess_iflow == random_num:</p><p class="MsoNormal" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; border-collapse: collapse; font-family: arial, sans-serif; font-size: 13px; ">                print &quot;&quot;&quot;That was right! I guess you&#39;re smarter than me...</p>
<p class="MsoNormal" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; border-collapse: collapse; font-family: arial, sans-serif; font-size: 13px; ">                even though it took you another try!&quot;&quot;&quot;</p>
<p class="MsoNormal" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; border-collapse: collapse; font-family: arial, sans-serif; font-size: 13px; "><br></p><p class="MsoNormal" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; border-collapse: collapse; font-family: arial, sans-serif; font-size: 13px; ">
Ok you said this program is for children. I think the flow of ifs and elifs might be a little complex for a child.</p><p class="MsoNormal" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; border-collapse: collapse; font-family: arial, sans-serif; font-size: 13px; ">
<br></p><p class="MsoNormal" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; border-collapse: collapse; font-family: arial, sans-serif; font-size: 13px; ">Why not set it up like this for a first try for a child programmer?</p>
<p class="MsoNormal" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; border-collapse: collapse; font-family: arial, sans-serif; font-size: 13px; "><br></p><p class="MsoNormal" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; border-collapse: collapse; font-family: arial, sans-serif; font-size: 13px; ">
Generate random number</p><p class="MsoNormal" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; border-collapse: collapse; font-family: arial, sans-serif; font-size: 13px; ">Ask for a guess</p>
<p class="MsoNormal" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; border-collapse: collapse; font-family: arial, sans-serif; font-size: 13px; ">if guess is too high say &quot;to high&quot;</p>
<p class="MsoNormal" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; border-collapse: collapse; font-family: arial, sans-serif; font-size: 13px; ">if guess is too low say &quot;to low&quot;</p>
<p class="MsoNormal" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; border-collapse: collapse; font-family: arial, sans-serif; font-size: 13px; ">if guess equeals the random number &quot;you got it, exit&quot;</p>
<p class="MsoNormal" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; border-collapse: collapse; font-family: arial, sans-serif; font-size: 13px; ">repeat</p><p class="MsoNormal" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; border-collapse: collapse; font-family: arial, sans-serif; font-size: 13px; ">
<br></p><p class="MsoNormal" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><font class="Apple-style-span" face="arial, sans-serif"><span class="Apple-style-span" style="border-collapse: collapse;">You can eliminate that whole second flow if you just have it repeat the process each time with a new guess input from the child. </span></font></p>
<p class="MsoNormal" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><font class="Apple-style-span" face="arial, sans-serif"><span class="Apple-style-span" style="border-collapse: collapse;"><br>
</span></font></p><p class="MsoNormal" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><font class="Apple-style-span" face="arial, sans-serif"><span class="Apple-style-span" style="border-collapse: collapse;">This also enables you to guess an unlimited amount of times at the answer each time comming closer and closer. Its kind of a cool game for a first try. </span></font></p>
<p class="MsoNormal" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; border-collapse: collapse; font-family: arial, sans-serif; font-size: 13px; "> </p><br><div class="gmail_quote">On Sat, Mar 5, 2011 at 6:38 PM, Julie Bell <span dir="ltr">&lt;<a href="mailto:jmwebstuff@yahoo.com">jmwebstuff@yahoo.com</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;"><table cellspacing="0" cellpadding="0" border="0"><tbody><tr><td valign="top" style="font:inherit">I am not a true python programmer. But I&#39;d put the repeating messages into a subroutine.<br>
1. To save on code space<br>2.  To be able to change message in one place<br>3. Easier Readability of program<br><br>The other thing I would do is put it into a loop the tries.<br><br><br> #simple number guessing game<br>
<br>import random<br><br>def correct():<div class="im"><br>        print &quot;You got it! I guess you are smarter than me!&quot;<br></div>    return<br><br>def correct2():<div class="im"><br>        print &quot;&quot;&quot;That was right! I guess you&#39;re smarter than me...<br>
        even though it took you another try!&quot;&quot;&quot;<br></div>    return<br><br>def wrong(random_num):<div class="im"><br><br>        print &quot;Nope! I&#39;m smarter than
 you!&quot;<br>        print &quot;I was thinking of the number: &quot;, random_num<br></div>    return <br><div class="im"><br>def main():<br><br>    print &quot;Do you think you&#39;re smarter than me?&quot;<br>    print &quot;I guess we&#39;ll see!&quot;<br>
    print &quot;I&#39;m thinking of a number between 0 - 100.  Can you guess what it is?&quot;<br>    print<br><br><br>    guess = input(&quot;Type a number between 0 - 100: &quot;)<br>    random_num = random.randrange(0,100,1)<br>
<br>    if guess == random_num:<br></div>    correct()<div class="im"><br> <br>    elif guess &lt; random_num:<br><br>            # user gets second chance if number is too low<br>            guess_iflow = input(&quot;You were too low. Type another number:
 &quot;)<br><br>            if guess_iflow == random_num:<br></div>        correct2()<br>            else:<br>        wrong(random_num)<div class="im"><br><br>    elif guess &gt; random_num:<br><br>            # user gets second chance if number is too high<br>
            guess_ifhigh = input(&quot;You were too high. Type another number: &quot;)<br><br>            if guess_ifhigh == random_num:<br></div>        correct2()<br>            else:<br>        wrong(random_num)<br>    else:<br>
   
 wrong(random_num)<br><br>main()<br><br><br>--- On <b>Sat, 3/5/11, kirby urner <i>&lt;<a href="mailto:kirby.urner@gmail.com" target="_blank">kirby.urner@gmail.com</a>&gt;</i></b> wrote:<br><blockquote style="border-left:2px solid rgb(16, 16, 255);margin-left:5px;padding-left:5px">
<br>From: kirby urner &lt;<a href="mailto:kirby.urner@gmail.com" target="_blank">kirby.urner@gmail.com</a>&gt;<br>Subject: Re: [Chicago] How could I make this better?<br>To: &quot;The Chicago Python Users Group&quot; &lt;<a href="mailto:chicago@python.org" target="_blank">chicago@python.org</a>&gt;<br>
Date: Saturday, March 5, 2011, 5:28 PM<div><div></div><div class="h5"><br><br><div>Is you goal to share the source code with your kids?<div><br></div><div>Dunno how young, but you might wanna make the if / elif / else stuff less deep.  Just ifs, without elifs or elses might be cool.</div>
<div><br></div><div>
I&#39;d probably make it a while True loop (with break conditions).  A blank guess might mean &quot;I give up&quot; (nice to have an escape route).</div><div><br></div><div>Chances of guessing the number in one or two guesses is about nil.</div>

<div><br></div><div>I&#39;d think the proposer of this puzzle wan&#39;t very smart if I had to play such a game.  :)</div><div><br></div><div>Note that in Python 3, input returns a string, not an integer (so convert -- but you can catch a blank first, as distinct from 0).</div>

<div><br></div><div>If your goal is to teach Python to your kids, I&#39;d recommend Python 3.</div><div><br></div><div>Kirby</div><div><br><div>On Sat, Mar 5, 2011 at 4:34 PM, Malcolm Newsome <span dir="ltr">&lt;<a rel="nofollow" href="http://mc/compose?to=malcolm.newsome@gmail.com" target="_blank">malcolm.newsome@gmail.com</a>&gt;</span> wrote:<br>

<blockquote style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204, 204, 204);padding-left:1ex"><div lang="EN-US"><div><p>Hey all.  I wrote this simple program for my children today.  I’m wondering if there was a more efficient alternative to the way I wrote it.</p>

<p> </p><p> </p><p> </p><p># guess.py</p><p># a simple number guessing game</p><p> </p><p>import random</p>
<p> </p><p>def main():</p><p> </p><p>    print &quot;Do you think you&#39;re smarter than me?&quot;</p><p>    print &quot;I guess we&#39;ll see!&quot;</p>
<p>    print &quot;I&#39;m thinking of a number between 0 - 100.  Can you guess what it is?&quot;</p><p>    print</p><p> </p><p>    guess = input(&quot;Type a number between 0 - 100: &quot;)</p>
<p> </p><p>    random_num = random.randrange(0,100,1)</p><p> </p><p>    if guess == random_num:</p><p>        print &quot;You got it! I guess you are smarter than me!&quot;</p>
<p> </p><p>    elif guess &lt; random_num:</p><p>            # user gets second chance if number is too low</p><p>            guess_iflow = input(&quot;You were too low. Type another number: &quot;)</p>
<p> </p><p>            if guess_iflow == random_num:</p><p>                print &quot;&quot;&quot;That was right! I guess you&#39;re smarter than me...</p><p>
                even though it took you another try!&quot;&quot;&quot;</p><p> </p><p>            else:</p><p>                print &quot;Nope! I&#39;m smarter than you!&quot;</p>
<p>                print &quot;I was thinking of the number: &quot;, random_num</p><p> </p><p>    elif guess &gt; random_num:</p><p>            # user gets second chance if number is too high</p>
<p>            guess_ifhigh = input(&quot;You were too high. Type another number: &quot;)</p><p> </p><p>            if guess_ifhigh == random_num:</p><p>
                print &quot;&quot;&quot;That was right! I guess you&#39;re smarter than me...</p><p>                even though it took you another try!&quot;&quot;&quot;</p><p> </p><p>
            else:</p><p>                print &quot;Nope! I&#39;m smarter than you!&quot;</p><p>                print &quot;I was thinking of the number: &quot;, random_num</p><p>
 </p><p>    else:</p><p>        print &quot;Nope! I&#39;m smarter than you!&quot;</p><p>        print &quot;I was thinking of the number: &quot;, random_num</p><p>
 </p><p>main()</p><p> </p></div></div><br>_______________________________________________<br>
Chicago mailing list<br>
<a rel="nofollow" href="http://mc/compose?to=Chicago@python.org" target="_blank">Chicago@python.org</a><br>
<a rel="nofollow" href="http://mail.python.org/mailman/listinfo/chicago" target="_blank">http://mail.python.org/mailman/listinfo/chicago</a><br>
<br></blockquote></div><br></div>
</div><br></div></div>-----Inline Attachment Follows-----<div class="im"><br><br><div>_______________________________________________<br>Chicago mailing list<br><a href="http://mc/compose?to=Chicago@python.org" target="_blank">Chicago@python.org</a><br>
<a href="http://mail.python.org/mailman/listinfo/chicago" target="_blank">http://mail.python.org/mailman/listinfo/chicago</a><br></div></div></blockquote></td></tr></tbody></table><br>

      <br>_______________________________________________<br>
Chicago mailing list<br>
<a href="mailto:Chicago@python.org">Chicago@python.org</a><br>
<a href="http://mail.python.org/mailman/listinfo/chicago" target="_blank">http://mail.python.org/mailman/listinfo/chicago</a><br>
<br></blockquote></div><br></div>