Re: [Tutor] Help with Guess the number script
On Mar 11, 2014, at 1:57 AM, Alan Gauld wrote: > OK so far, you don't need all the print statements > but that's just a style issue. (You could just > insert '\n' characters instead.) You’re right, I’m actually not sure why I did it that way. > >> if guess < secret - 10 or guess > secret - 10: > > This is the right idea for cutting the line count but you > have the comparison values wrong. Look back to earlier > emails, you are repeating the same error as before. > Manually think through what happens in the line above > if guess == secret. Oh, do you mean it should be <= and >=?? I’m not sure why that would work, because if guess==secret I have another statement in my code that takes care of that. I didn’t want to add my whole code because it’s too long but that is in there. > > And then once you get that fixed you can rewrite using > the chained comparison trick to tidy it up. > ie > if not (lower limit < guess > upper limit): I see what you’re saying about the chained comparison. What I’m having problems with is condensing it to half the lines of code so I don’t have to have the same conditionals under both ‘too low’ and ‘to high’. If that makes sense. > > ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Help with Guess the number script
On Mar 10, 2014, at 11:18 PM, Dave Angel wrote: > if guess < secret - 10 or guess > secret - 10: > > Think about that line. You might even want to put in a separate > function to test what it does. > HINT: it's wrong. > Got it! I realized what I was doing wrong. I needed that plus sign for the too high part of it and what you said helped me figure it out! Thanks Dave, all you actually! ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
[Tutor] Loop Issue
Hello all, I was following along in a book called 'Python Programming for the Absolute Beginner' by Michael Dawson and I ran into an odd problem with a loop. Dawson has the following code in his book: health = 10 trolls = 0 damage = 3 while health != 0: trolls += 1 health -= damage This seems simple enough. (This is an example of a non-terminating loop, by the way, so it is not suppose to work correctly.) My problem is that when I enter this into IDLE, and hot enter a few times. I never get my prompt (>>>) back. It just lets me hot enter a bunch of time as though it is expecting more input from me. I tried making a similar loop and it gave me my prompt back just fine. Does anyone know what might be going on here? Thanks, Yanni ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] c++ on python
On 11/03/14 14:27, Gabriele Brambilla wrote: Is it a library or a program? A program. it should use only standard C++ libraries. OK, If it's a program, that is, it compiles into an executable that you can run then you can run it from within Python using the subprocess module. Do you know how you interact with it? Can you give it start up arguments? Does it read from stdin? Does it write to stdout? Does it read a data file? Does it write a file out? You will need to know that to be able to use the program from inside Python. What do you mean about using Python to work with it? > How do you usually do? I mean running the C++ program and exchanging data with it. That's what subprocess allows you to do. If it were a library then you would have to call the individual C++ functions directly using something like ctypes, which is usually more complex. -- Alan G Author of the Learn to Program web site http://www.alan-g.me.uk/ http://www.flickr.com/photos/alangauldphotos ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Trying to read dBase files
On 11/03/14 20:09, Dave Angel wrote: Alan Gauld Wrote in message: I am using Python 3.3. I did some google searches and found something called dbfpy to read dbase, so I downloaded and installed it. File "C:\Python33\lib\site-packages\dbfpy\dbf.py", line 260 print repr(_rec) ^ SyntaxError: invalid syntax Which is in the dbfpy code. Oops, good catch Dave, I didn't notice the file name... So yes it looks like the OP needs a v3 version of the dbfpy package. Or a different approach. -- Alan G Author of the Learn to Program web site http://www.alan-g.me.uk/ http://www.flickr.com/photos/alangauldphotos ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Loop Issue
On 11/03/14 13:53, Yanni Phone wrote: health = 10 trolls = 0 damage = 3 while health != 0: trolls += 1 health -= damage This seems simple enough. (This is an example of a non-terminating loop, by the way, so it is not suppose to work correctly.) My problem is that when I enter this into IDLE, and hot enter a few times. > I never get my prompt (>>>) back. That's because, as you just said, its a non-terminating loop. The prompt only returns when the loop ends, which is currently never. You will need to interrupt the loop (using Ctrl-C?) and fix the bug. -- Alan G Author of the Learn to Program web site http://www.alan-g.me.uk/ http://www.flickr.com/photos/alangauldphotos ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Help with Guess the number script
On 03/12/2014 05:13 AM, Scott Dunning wrote: >> if guess < secret - 10 or guess > secret - 10: > >This is the right idea for cutting the line count but you >have the comparison values wrong. Look back to earlier >emails, you are repeating the same error as before. >Manually think through what happens in the line above >if guess == secret. Oh, do you mean it should be <= and >=?? I’m not sure why that would work, because if guess==secret I have another statement in my code that takes care of that. I didn’t want to add my whole code because it’s too long but that is in there. Such errors are either obvious or invisible. A remedy is often to figure the problem on paper (or in your head if you're good at thinking visually). Here, just draw a line segment with secret in the middle and the interval borders around. Then, write there on the drawing the _values_ of the borders, as arithmetic expressions. d ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Help with Guess the number script
Scott W Dunning Wrote in message: > > On Mar 11, 2014, at 7:50 PM, William Ray Wing wrote: >> >> Simple. In Mail Preferences -> Composing -> Message Format -> Plain Text >> (Your setting is probably currently Rich Text.) >> > Got it, hopefully that helps. Perfect, thanks. -- DaveA ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Trying to read dBase files
On 12/03/2014 09:13, Alan Gauld wrote: On 11/03/14 20:09, Dave Angel wrote: Alan Gauld Wrote in message: I am using Python 3.3. I did some google searches and found something called dbfpy to read dbase, so I downloaded and installed it. File "C:\Python33\lib\site-packages\dbfpy\dbf.py", line 260 print repr(_rec) ^ SyntaxError: invalid syntax Which is in the dbfpy code. Oops, good catch Dave, I didn't notice the file name... So yes it looks like the OP needs a v3 version of the dbfpy package. Or a different approach. Or run 2to3 against dbfpy. -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence --- This email is free from viruses and malware because avast! Antivirus protection is active. http://www.avast.com ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] c++ on python
Alan Gauld, 12.03.2014 10:11: > If it were a library then you would have to call > the individual C++ functions directly using > something like ctypes, which is usually more > complex. ctypes won't talk to C++, but Cython can do it quite easily. Stefan ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
[Tutor] how do i delete the questions that i asked and it has been shared in web
this one http://code.activestate.com/lists/python-tutor/99408/ and there are other ones as well ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] how do i delete the questions that i asked and it has been shared in web
On Wed, Mar 12, 2014 at 12:46 PM, S Tareq wrote: > this one http://code.activestate.com/lists/python-tutor/99408/ > > and there are other ones as well This is a mailing list. Once an email is sent, you can't unsend it. -- Zach ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] how do i delete the questions that i asked and it has been shared in web
so you can't delete the question that i have asked long time ago On Wednesday, 12 March 2014, 18:03, Zachary Ware wrote: On Wed, Mar 12, 2014 at 12:46 PM, S Tareq wrote: > this one http://code.activestate.com/lists/python-tutor/99408/ > > and there are other ones as well This is a mailing list. Once an email is sent, you can't unsend it. -- Zach ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] how do i delete the questions that i asked and it has been shared in web
No. On Wed, Mar 12, 2014 at 1:33 PM, S Tareq wrote: > so you can't delete the question that i have asked long time ago > > > On Wednesday, 12 March 2014, 18:03, Zachary Ware > wrote: > On Wed, Mar 12, 2014 at 12:46 PM, S Tareq wrote: > >> this one http://code.activestate.com/lists/python-tutor/99408/ >> >> and there are other ones as well > > > This is a mailing list. Once an email is sent, you can't unsend it. > > -- > Zach > ___ > Tutor maillist - Tutor@python.org > To unsubscribe or change subscription options: > https://mail.python.org/mailman/listinfo/tutor > > > > > ___ > Tutor maillist - Tutor@python.org > To unsubscribe or change subscription options: > https://mail.python.org/mailman/listinfo/tutor > ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] how do i delete the questions that i asked and it has been shared in web
In fact all of these messages are being distributed and saved to various mailing list web mirrors as we send them. Your requests to delete the message will also appear pretty soon after you send them. On Wed, Mar 12, 2014 at 2:38 PM, Tim Krupinski wrote: > No. > > On Wed, Mar 12, 2014 at 1:33 PM, S Tareq wrote: > > so you can't delete the question that i have asked long time ago > > > > > > On Wednesday, 12 March 2014, 18:03, Zachary Ware > > wrote: > > On Wed, Mar 12, 2014 at 12:46 PM, S Tareq wrote: > > > >> this one http://code.activestate.com/lists/python-tutor/99408/ > >> > >> and there are other ones as well > > > > > > This is a mailing list. Once an email is sent, you can't unsend it. > > > > -- > > Zach > > ___ > > Tutor maillist - Tutor@python.org > > To unsubscribe or change subscription options: > > https://mail.python.org/mailman/listinfo/tutor > > > > > > > > > > ___ > > Tutor maillist - Tutor@python.org > > To unsubscribe or change subscription options: > > https://mail.python.org/mailman/listinfo/tutor > > > ___ > Tutor maillist - Tutor@python.org > To unsubscribe or change subscription options: > https://mail.python.org/mailman/listinfo/tutor > ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] how do i delete the questions that i asked and it has been shared in web
On 12/03/14 17:46, S Tareq wrote: this one http://code.activestate.com/lists/python-tutor/99408/ and there are other ones as well As others have said you can't delete them One of the features of a mailing list is that everyone on the list has a copy of the email and can keep that for as long as they wish. The point of the web mirrors is to provide an archive so you can search to see if anyone else has already asked the same question. If it were possible to delete old mails that knowledge would be lost. Anything you post to a public mailing list in effect becomes public property -- Alan G Author of the Learn to Program web site http://www.alan-g.me.uk/ http://www.flickr.com/photos/alangauldphotos ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] c++ on python
On 12/03/14 16:49, Stefan Behnel wrote: Alan Gauld, 12.03.2014 10:11: If it were a library then you would have to call the individual C++ functions directly using something like ctypes, which is usually more complex. ctypes won't talk to C++, but Cython can do it quite easily. I thought it would work provided the interface functions were declared as C functions? That might involve writing a wrapper around it but that is usually trivial if you have to compile the source anyway. -- Alan G Author of the Learn to Program web site http://www.alan-g.me.uk/ http://www.flickr.com/photos/alangauldphotos ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Help with Guess the number script
> > Such errors are either obvious or invisible. A remedy is often to figure the > problem on paper (or in your head if you're good at thinking visually). > Here, just draw a line segment with secret in the middle and the interval > borders around. Then, write there on the drawing the _values_ of the > borders, as arithmetic expressions. Very much so. Diagrams are important. Not everything is textual. (Which you might consider with some irony based on some of the meta-discussion on this thread.) See some of the problem-solving heuristics described in: http://en.wikipedia.org/wiki/How_to_Solve_It "Can you think of a picture or a diagram that might help you understand the problem?" ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Loop Issue
This particular loop condition looks very suspicious. I would look at it more closely. When is it false? When is it true? ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Loop Issue
On 12/03/2014 23:18, Danny Yoo wrote: This particular loop condition looks very suspicious. I would look at it more closely. When is it false? When is it true? Context please Danny, we're not all mind readers and we don't all have photographic memories :) -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence --- This email is free from viruses and malware because avast! Antivirus protection is active. http://www.avast.com ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Loop Issue
The context is the beginning of the thread: https://mail.python.org/pipermail/tutor/2014-March/100543.html with the loop: ### while health != 0: ... ### ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
[Tutor] Project suggestions
Hey Everyone, I just got through doing a Guess-the-number script and was looking for something else to practice on. Do any of you have any suggestions on some things I could work on? Keep in mind I am not only extremely new to python I am new to programming. Thanks for any suggestions!!! Scott ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Project suggestions
Scott W Dunning writes: > I just got through doing a Guess-the-number script and was looking for > something else to practice on. Do any of you have any suggestions on > some things I could work on? Keep in mind I am not only extremely new > to python I am new to programming. Thanks for any suggestions!!! You've received the suggestion, but I'll recommend it again: Newcomers to Python should work through the Python Tutorial http://docs.python.org/3/tutorial/>. Run each example yourself, experiment at the interactive Python prompt to understand it, before continuing through the tutorial. -- \“Humanity has advanced, when it has advanced, not because it | `\ has been sober, responsible, and cautious, but because it has | _o__)been playful, rebellious, and immature.” —Tom Robbins | Ben Finney ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor