<div dir="ltr"><div class="gmail_default" style="font-family:arial,helvetica,sans-serif;font-size:small;color:#0b5394">Sounds like a circular import problem: lookup circular import in Python.</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Apr 14, 2015 at 10:55 AM, Michael Havens <span dir="ltr"><<a href="mailto:bmike1@gmail.com" target="_blank">bmike1@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">I was wondering:<div> after I loaded the libraries an imported randinit when I run the program it says: </div><div><br></div><div> ImportError: cannot import name randinit</div><div><br></div><div>does this mean I need to install something? My duckduckgo search ("ImportError: cannot import name randinit" python) gave me a big 'nothing found' message.</div></div><div class="gmail_extra"><br clear="all"><div><div>:-)~MIKE~(-:</div></div><div><div class="h5">
<br><div class="gmail_quote">On Mon, Apr 13, 2015 at 1:14 PM, Todd Millecam <span dir="ltr"><<a href="mailto:tyggna@gmail.com" target="_blank">tyggna@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Here's mine, you're pretty much right on track now. I thought I'd include this just to introduce a few new concepts and help you think a little more like a computer.<br><div><br></div><div>#!/usr/bin/env python<br>#This first line is really nifty, and all Linux users should be familiar with this.<br># If you pass this file into python, the first line gets ignored, but if you pass it into bash or sh, then a # and a ! are called a magic byte, or whiz-bang for short<br># They tell bash to open the rest of this file using the program and arguments passed on the first line. <br># So this line changes my python script into a bash program, and if I had saved this as /tmp/myguess.py, I could then, from a bash prompt type in /tmp/myguess.py to run it</div><div><br>from random import randint</div><div># Right after the first line, it's polite to import all your libraries and functions right at the top. This particular one says I want, from the "random" library to get a function called "randint"<br># randint returns a random integer in a specified range<br># The rest of the file is my actual program<br><br></div><div>answer = randint(0,10)</div><div>guess = int() # this is called an uninitialized integer. It has the space of ram allocated, but no value placed in it yet. These tend to be about 100x faster than initialized data types</div><div>while guess is not answer: #same thing as guess != answer</div><div> if guess is int(): # I only want something printed after they've guessed</div><div> pass </div><div> else:</div><div> print("Wrong.")<br> #Since this part is at the same indentation level as the if and else, it will always get executed</div><div> g = input("Guess my number: ")</div><div> guess = int(g)</div><div>print("Correct!")</div><div><br></div><br><br></div><div class="gmail_extra"><div><div><br><div class="gmail_quote">On Mon, Apr 13, 2015 at 1:48 PM, Sesso <span dir="ltr"><<a href="mailto:sesso@djsesso.com" target="_blank">sesso@djsesso.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word">You may be better off using if statements.<div><br></div><div><br></div><div>If number is less than 5</div><div><br></div><div>print guess higher</div><div><br></div><div>else </div><div><br></div><div>print guess lower</div><div><br></div><div>Then wrap all of that in a while loop with a condition of while less than 5.</div><div><br></div><div>Jason</div><div><div><div><br></div><div><br></div><div><br><div><blockquote type="cite"><div>On Apr 13, 2015, at 12:44 PM, Michael Havens <<a href="mailto:bmike1@gmail.com" target="_blank">bmike1@gmail.com</a>> wrote:</div><br><div><div dir="ltr">however it does give suggestions on subsequent guesses....</div><div class="gmail_extra"><br clear="all"><div><div>:-)~MIKE~(-:</div></div>
<br><div class="gmail_quote">On Mon, Apr 13, 2015 at 12:42 PM, Michael Havens <span dir="ltr"><<a href="mailto:bmike1@gmail.com" target="_blank">bmike1@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">here is what I have (that sorta works):<div><br></div><div><span><div>print("Welcome.")</div><div>g = input("Guess the number: ")</div><div>guess = int(g)</div></span><div>while guess < 5:</div><span><div> g = input("Guess the number: ")</div><div> guess = int(g)</div></span><div> print("Guess higher.")</div><div>while guess > 5:</div><span><div> g = input("Guess the number: ")</div><div> guess = int(g)</div></span><div> print ("Guess lower.")</div><div>print("Correct")</div></div><div><br></div><div> What I mean by 'sorta' is if the first guess is not correct it does not give a suggestion to guess lower or higher. Why is this?</div><div class="gmail_extra"><br clear="all"><div><div>:-)~MIKE~(-:</div></div><div><div>
<br><div class="gmail_quote">On Mon, Apr 13, 2015 at 12:32 PM, Michael Havens <span dir="ltr"><<a href="mailto:bmike1@gmail.com" target="_blank">bmike1@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">that makes sense... thanks!</div><div class="gmail_extra"><br clear="all"><div><div>:-)~MIKE~(-:</div></div><div><div>
<br><div class="gmail_quote">On Mon, Apr 13, 2015 at 12:31 PM, Sesso <span dir="ltr"><<a href="mailto:sesso@djsesso.com" target="_blank">sesso@djsesso.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word"><div>The while needs to before input so that it will wait for input if the variable is not equal to 5.</div><div><br></div><div>Jason</div><div><div><div><br></div><div><br></div><div><blockquote type="cite"><div>On Apr 13, 2015, at 12:21 PM, Michael Havens <<a href="mailto:bmike1@gmail.com" target="_blank">bmike1@gmail.com</a>> wrote:</div><br><div><div dir="ltr">nope. that didn't fix it.<br><br></div><div class="gmail_extra"><br clear="all"><div><div>:-)~MIKE~(-:</div></div>
<br><div class="gmail_quote">On Mon, Apr 13, 2015 at 11:46 AM, Amit Nepal <span dir="ltr"><<a href="mailto:amit@amitnepal.com" target="_blank">amit@amitnepal.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">You would probably want to wait and ask for the input inside the loop as well. What you seem to be doing is you ask for input and then you execute the loop not letting the user input the new number and thus running into an infinite loop.<br>
<br>
This might fix it, not tested though :)<span><br>
<br>
print("Welcome.")<br>
g = input("Guess the number: ")<br>
guess = int(g)<br>
<br>
while guess != 5<br>
print("Guess again.")<br></span>
guess = int(g)<br>
print("Correct")<br>
<br>
<br>
Thanks<span><font color="#888888"><br>
Amit</font></span><span><br>
On 4/13/2015 11:01 AM, Michael Havens wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
print("Welcome.")<br>
g = input("Guess the number: ")<br>
guess = int(g)<br>
while guess != 5:<br>
print("Guess again.")<br>
print("Correct")<br>
</blockquote>
<br></span><div><div>
------------------------------<u></u>---------------------<br>
PLUG-discuss mailing list - <a href="mailto:PLUG-discuss@lists.phxlinux.org" target="_blank">PLUG-discuss@lists.phxlinux.<u></u>org</a><br>
To subscribe, unsubscribe, or to change your mail settings:<br>
<a href="http://lists.phxlinux.org/mailman/listinfo/plug-discuss" target="_blank">http://lists.phxlinux.org/<u></u>mailman/listinfo/plug-discuss</a><br>
</div></div></blockquote></div><br></div>
---------------------------------------------------<br>PLUG-discuss mailing list - <a href="mailto:PLUG-discuss@lists.phxlinux.org" target="_blank">PLUG-discuss@lists.phxlinux.org</a><br>To subscribe, unsubscribe, or to change your mail settings:<br><a href="http://lists.phxlinux.org/mailman/listinfo/plug-discuss" target="_blank">http://lists.phxlinux.org/mailman/listinfo/plug-discuss</a></div></blockquote></div><br></div></div></div><br>---------------------------------------------------<br>
PLUG-discuss mailing list - <a href="mailto:PLUG-discuss@lists.phxlinux.org" target="_blank">PLUG-discuss@lists.phxlinux.org</a><br>
To subscribe, unsubscribe, or to change your mail settings:<br>
<a href="http://lists.phxlinux.org/mailman/listinfo/plug-discuss" target="_blank">http://lists.phxlinux.org/mailman/listinfo/plug-discuss</a><br></blockquote></div><br></div></div></div>
</blockquote></div><br></div></div></div></div>
</blockquote></div><br></div>
---------------------------------------------------<br>PLUG-discuss mailing list - <a href="mailto:PLUG-discuss@lists.phxlinux.org" target="_blank">PLUG-discuss@lists.phxlinux.org</a><br>To subscribe, unsubscribe, or to change your mail settings:<br><a href="http://lists.phxlinux.org/mailman/listinfo/plug-discuss" target="_blank">http://lists.phxlinux.org/mailman/listinfo/plug-discuss</a></div></blockquote></div><br></div></div></div></div><br>---------------------------------------------------<br>
PLUG-discuss mailing list - <a href="mailto:PLUG-discuss@lists.phxlinux.org" target="_blank">PLUG-discuss@lists.phxlinux.org</a><br>
To subscribe, unsubscribe, or to change your mail settings:<br>
<a href="http://lists.phxlinux.org/mailman/listinfo/plug-discuss" target="_blank">http://lists.phxlinux.org/mailman/listinfo/plug-discuss</a><br></blockquote></div><br><br clear="all"><div><br></div>-- <br></div></div><span><font color="#888888"><div>Todd Millecam</div>
</font></span></div>
<br>---------------------------------------------------<br>
PLUG-discuss mailing list - <a href="mailto:PLUG-discuss@lists.phxlinux.org" target="_blank">PLUG-discuss@lists.phxlinux.org</a><br>
To subscribe, unsubscribe, or to change your mail settings:<br>
<a href="http://lists.phxlinux.org/mailman/listinfo/plug-discuss" target="_blank">http://lists.phxlinux.org/mailman/listinfo/plug-discuss</a><br></blockquote></div><br></div></div></div>
<br>---------------------------------------------------<br>
PLUG-discuss mailing list - <a href="mailto:PLUG-discuss@lists.phxlinux.org">PLUG-discuss@lists.phxlinux.org</a><br>
To subscribe, unsubscribe, or to change your mail settings:<br>
<a href="http://lists.phxlinux.org/mailman/listinfo/plug-discuss" target="_blank">http://lists.phxlinux.org/mailman/listinfo/plug-discuss</a><br></blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature"><div dir="ltr"><font color="#0b5394">James</font><div><br><span style="color:rgb(255,255,255)"><span style="background-color:rgb(11,83,148)"><b><a href="http://www.linkedin.com/pub/james-h-dugger/15/64b/74a/" target="_blank"><span style="background-color:rgb(255,255,255)"><span></span><span style="color:rgb(11,83,148)">Linkedin<span></span></span></span></a></b></span></span><br></div></div></div>
</div>