Re: [Tutor] Need help on How to Think Like a Computer Scientist: Learning with Python.
I don't know of any answer list but one you can ask for help here or what I do when I have a question i stop working on it for anywhere from an hour to a week and go back to it you will solve it if you solve it in your sleep well thats a whole other issue but that does happen. -Amadeo On 8/15/07, Vanneth Tea [EMAIL PROTECTED] wrote: Hello All, I am new to computer programming and chose to learn Python. Now I am stuck with certain codes that I need help. Please let me know if there is an answer list to the exercises in How to Think Like a Computer Scientist: Learning with Python. I followed and did good on most of the exercises but I have been stuck on a few of them which burned me up after spending days and nights trying to make them works. I hope you understand the feeling when you are stuck and need a drop of water to keep alive. I really appreciate any assistance you can give. Thanks. Fussy? Opinionated? Impossible to please? Perfect. Join Yahoo!'s user panel and lay it on us. http://surveylink.yahoo.com/gmrs/yahoo_panel_invite.asp?a=7 ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Online Rock Paper Sizzors
thank you very much ill start on it right away its just going to be a text based game client cause i want it to work on my old computer Pentium 1 On 6/22/07, Alan Gauld [EMAIL PROTECTED] wrote: From: Amadeo Bellotti [EMAIL PROTECTED] no this isn't a home work assignment. Ok, Just checking :-) Ive never done web programming before i am pretty skilled in python i dont want an application like on a web browser. OK, That would have been the simplest form of online game but... i want a client that each person can download. OK, I assume from this that you want a multi player game - for rock,paper,scissors I assume multi = 2? - rather than just an interactive game against the computer? honestly i have no clue where to start with a web app OK, If we are going for a networked game between multiple users you have a choice to run a server centrally with all clients connecting to that or to run on a peer to per basis with the two participating machines forming a direct connection. The latter is easy to program for the game but more complex to set up the initial configuration. A central server makes the game slightly more comlex but setup is easier. I'd probably opt for the server approach but keep it really simple initially. Only allow two connections and simply relay the results. This can all be done using simple sockets (see my network programming topic on my tutor). The sequence will be something like: server awaiting connections client A connects, server gives back (empty) list of other clients client B connects, server notifies all clients of user list client B challenges A (or vice versa) server notifies A that he has been challenged A accepts and server henceforth refuses any more connections server asks players to select a weapon clients send responses server compares responses and sends notification to both cliernts of score repeat for as many turns as desired then report final score open up for more connections client C connects server notifies all clients of new user list client A challenges C repeat as above... Hopefully that's enough to give you somne ideas and get started. Once you get that working you can enhance it to support multiple games at once etc. Keep high scores, league tables etc etc. Also you can introduce security with logins etc. But get the basic game structure working first. HTH, -- Alan Gauld Author of the Learn to Program web site http://www.freenetpages.co.uk/hp/alan.gauld ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] Online Rock Paper Sizzors
any body know where i start with this I want to be able to enter user names and keep score for the persons wins and loses anybody know how i can do this? ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] Converting a string to a list with each character as an item
does anyone know how to do this? I need it because i want to make a binary coverter ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] OT What's next
thank you soo much Alan i have Sams teach yourself C in 21 days fr starters is that any good? On 11/30/06, Alan Gauld [EMAIL PROTECTED] wrote: Amadeo Bellotti [EMAIL PROTECTED] wrote step two sites to learn anyone know where i can look up c programming for linux? Ah! Now, if you'd said you were talking about a Linux PC then there would be no question. C is the only way to go. The Linux documentation project has loads of stuff about programming for Linux, but you need to learn C first. My personal choices for books are: 1) The original C Language book by Kernighan Ritchie One of the finest programming tutorials ever written, great for core C but useless for the library functions. 2) C The Complete Reference by Schildt. A very good tutorial that also makes a good (albeit DOS oriented) reference manual. Online I haven't seen anything outstanding for C but then I haven't really looked at beginners tutorials because I could already program C before the web was invented! One thing - Don;t get sidetracked into C++. Its a whole different ballgame, much more complex and unnecessary if you want to go low level. HTH, Alan G. On 11/29/06, Terry Carroll [EMAIL PROTECTED] wrote: On Wed, 29 Nov 2006, R. Alan Monroe wrote: Pure assembler on a PC involves a huge amount of work for even the most trivial task. Some useful assembly tips here: http://www.grc.com/smgassembly.htm I never wanted to actually program assembly on the PC, but I did want to understand it (actually, I wanted to understand the Intel x86 architecture, and there's no better way of doing that than learning the assembly language for a machine). I read Jeff Duntemann's Assembly language Step-by-Step, http://duntemann.com/assembly.htm , and found it very useful, although I didn't actually try any programming. I'm an old mainframe assembler language hack from way back in the IBM System/370 days (although in my last development job, I wrote more in machine code than in actual assembler), so I didn't really need or desire to do the practical aspects of actually writing x86 code; but I felt that would have been a good book to get me there, had that been what I wanted. A couple of years ago, I took a course in which I built a rudimentary computer around an Intel 8031 chip; and when I say built, I mean built. It was a couple dozen components on a breadboard, with about only about 2Kbytes of memory, if I recall; I soldered or wire-wrapped every connection. You really learn an architecture when you do that. not that I remember much of it anymore, two years later. Not a route I recommend. I needed a few credits to fill an obscure educational requirement, though, and this was a fun way to do it. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] OT What's next
I will I'm learning Java at school (icky i no) so i thought C+Java+Python would be redcilously strong(especially with Jython). On 11/30/06, Alan Gauld [EMAIL PROTECTED] wrote: Amadeo Bellotti [EMAIL PROTECTED] wrote i have Sams teach yourself C in 21 days fr starters is that any good? I haven't seen it but given you already know at least the basics of programming through Python I'm pretty sure it will be good enough to get you up and started in C. C is a very simple language with only about 20-3-0 reserved words. Like Python most of the power is in its library of functions. So learning the core language is easy, learning the functions can take a long time! But like Python you only need to learn as much as you need at any given time! Have fun, Alan G ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Python Linux Distro Anyone
Dave I looked at LAMP it really didn't have everything I need well more like want. I was thinking instead of Vi or emacs have a text editor written in python which would save a lot of space. Instead of lynx have one in python. On 11/29/06, Python [EMAIL PROTECTED] wrote: On Tue, 2006-11-28 at 22:45 -0500, Amadeo Bellotti wrote: I was thinking it would be really nice if i could make a Pocket Linux distro that of course fits on one or two floppies (outdated I no but still are amazing) thats just the Linux kernel, bash, and python. with of course a lot of tiny scripts to do daily business and/or recovery. You might want to look at puppyOS. http://www.puppyos.net/ It is designed to boot from USB memory and provides a small footprint OS. http://www.puppyos.net/pfs/ Describes how to build puppy from scratch (pfs) which would allow you to build your own tiny version. We could have a mail client, a text reader/editor, text based web browser, all in python. Of Course this will be a lot of work and it would be neat if the whole user group pitched in. so what I'm basically asking is that if you are interested email me and ill give you some detail. Shooting for a floppy disk based distribution is too much pain with too little gain for me. The puppy approach of a bootable OS that you can carry in your pocket is pretty slick. I'm using a 1 GB USB flash which is, for me, reasonably low cost and far better than carrying floppy disks. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor -- Lloyd Kvam Venix Corp ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] OT What's next
I've recently wanted to learn more about my hardware and i figured what better way then programming at the base level. I no it sounds stupid but i would like to learn to manage my own memory. so i was wondering if anyone has dipped there toe in either C or Assembly. If you have please tell me which one you prefer and were a good site is ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] Python Linux Distro Anyone
I was thinking it would be really nice if i could make a Pocket Linux distro that of course fits on one or two floppies (outdated I no but still are amazing) thats just the Linux kernel, bash, and python. with of course a lot of tiny scripts to do daily business and/or recovery. We could have a mail client, a text reader/editor, text based web browser, all in python. Of Course this will be a lot of work and it would be neat if the whole user group pitched in. so what I'm basically asking is that if you are interested email me and ill give you some detail. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] off topic GNOME background
my background just disappeared it shows a black screen like it cant find the default background. if that makes sense I've added my own and it cant seem to find it i removed it and re added it it doesn't seem to be working though anyone have any ideas? ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] Python Magazine
I no im probally not the best pereson to go about this but maybe people in this community are. I was wondering if there was or maybe someone can start a Python maganize kinda like 3dCreative or 2d Artist. that is an PDF magazine with tutorials interviews, python news, and maybe a programming challenge or two. and free would be nice i might start this but does anyone want to help maybe? ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Python Magazine
i saw it but it didnt quite meet what i wanted :\On 10/14/06, Glenn T Norton [EMAIL PROTECTED] wrote: Amadeo Bellotti wrote: I no im probally not the best pereson to go about this but maybe people in this community are. I was wondering if there was or maybe someone can start a Python maganize kinda like 3dCreative or 2d Artist. that is an PDF magazine with tutorials interviews, python news, and maybe a programming challenge or two. and free would be nice i might start this but does anyone want to help maybe? ___Tutor maillist-Tutor@python.orghttp://mail.python.org/mailman/listinfo/tutor #1, make it so...http://www.pyzine.com/--Ketchup. For the good times... - Ketchup Advisory BoardGlenn NortonApplication Developer Nebraska.gov1-402-471-2777[EMAIL PROTECTED] ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] tkinter tutorials
I am currently interseted in learning tkinter and what beeter way then with a project so im making a python IDE and i was wondering if there were any good tutorials that are out there for tkinter and a book or 2 would be nice thank you ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Some questions about my yen-USD.py
thats fine its just my dad would need that and it would be easier for him if he had the exchange rate bulit inOn 9/17/06, Dick Moores [EMAIL PROTECTED] wrote:At 07:10 PM 9/17/2006, Amadeo Bellotti wrote:ok i jsut wanted to say great program but i would like to see an acutal exchange rate like maybe get it from a website it would be somuch nicer and easier to use also it would help linux users who runfrom console so they dont have to look up the current rate online Thanks for the great suggestion. Right now I don't have the faintestidea how to implement it, but I'm sure going to try to learn how.Give me till Tuesday? ;)Dick ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Some questions about my yen-USD.py
ok i jsut wanted to say great program but i would like to see an acutal exchange rate like maybe get it from a website it would be so much nicer and easier to use also it would help linux users who run from console so they dont have to look up the current rate online On 9/17/06, Dick Moores [EMAIL PROTECTED] wrote: I'm bck!I kept getting ideas for what I (and some of you) thought was afinished yen-USD.py. And some of the good advice I got was to move onto other things. I did for a while, but I kept thinking up new revisions. The script has more than doubled in length. I'd previouslyposted v4 at http://www.rcblue.com/Python/yen-USD-v3.txt.Here's v10: http://www.rcblue.com/Python/yen-USD-v10.txtNew functions:again()divide2StringDecimals()multiply2StringDecimals()roundNumber() -- replaced setPrecision() printVariablesNotChanging()formatNumber()removeCommasFromNumbers()rather radically revised function:again()-- offers several more choicesThe most important change is that because I realized I wanted the program to be a general solution and give accurate answers for evenvery large amounts of Yen or USD, I decided to operate with (number)strings only, except when necessary in getRate() and getAmount() toerror check user inputs. Those floats are not used in the calculations of Yen or USD.The most difficult function for me to write was roundNumber(), whichof course couldn't rely on the use of the built-in round() or theformatting of strings (see the line format = %. + str(precision) + 'f' in setPrecision() in v3).Lack of experience with the slicingof lists caused many headaches. I didn't succeed in debugging until Iput in print statements wherever a value changes, and trying many different integer strings and places (the arguments ofroundNumber()). A good lesson, I think.I hope some of the Tutors will take a look at the new functions,especially roundNumber().Did I just reinvent the wheel? Should it be broken up into more sub-functions (there's only one now)?It works, but is it Pythonic? Etc.I'm also curious about multiply2StringDecimals() and divide2StringDecimals().Again, am I reinventing the wheel with these? Is there a simpler way to multiply and divide big decimals with precision?Thanks in advance,Dick Moores___Tutor maillist- Tutor@python.orghttp://mail.python.org/mailman/listinfo/tutor ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] [OT] some jobs are just too big for Python
Thats acutally a pretty good analogy but i think python isnt yet at its fullest potential or even closeOn 9/8/06, Terry Carroll [EMAIL PROTECTED] wrote: http://www.news.com.au/dailytelegraph/story/0,22049,20372915-5006003,00.htmlSummary: A python (the actual snake) ate an entire pregnant sheep inMalaysia; and was unable to even move afterwards.The story above includes an impressive if somewhat disturbing photo. ___Tutor maillist-Tutor@python.orghttp://mail.python.org/mailman/listinfo/tutor ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] GUI Programing
thank you all im reading up on it all its a diffreent mindset that i have tog et used toOn 9/1/06, Terry Carroll [EMAIL PROTECTED] wrote:On Fri, 1 Sep 2006, Alan Gauld wrote: Fred Lundh's tutorial is much better nowadays - although longer. Tkinter docs are tough enough to come by that, in my view, longer isbetter.___Tutor maillist-Tutor@python.org http://mail.python.org/mailman/listinfo/tutor ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] GUI Programing
I'm going to try some GUI programming does anyone know where the start like using tk or wx or what ever i want it to it will run on Windows UNIX and Mac systems can you tell me whats best to use and give me a link to a good tutorial? Thanks ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] File IO
the code is way to long but i can post the output of puzzleanswers Answer: 6 1 4 2 9 3 8 5 7 8 5 9 1 6 7 2 3 4 2 3 7 8 5 4 9 1 6 7 8 6 9 1 2 5 4 3 4 2 1 3 7 5 6 9 8 3 9 5 4 8 6 1 7 2 9 4 3 5 2 8 7 6 1 5 6 8 7 4 1 3 2 9 1 7 2 6 3 9 4 8 5 for those of you who dont know its a sudoku puzzle if you guys want i can attach the .py file.On 8/30/06, Alan Gauld [EMAIL PROTECTED] wrote: How do you know? Where are you looking for the file? Are you sure its not a Path issue? no no the file shows up in the same directory as the .py file and i no it works cause i read the text fileOK, In that case can you show us what puzzleanswers looks like? On 8/29/06, Kent Johnson [EMAIL PROTECTED] wrote: I would print filename print puzzleanswers to make sure you know what should happen.Also, if the code is not too long can you post it too?Alan G. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Can you tell me whats wrong with this code?
Thank you sooo much thats exactly what went wrong thank you so muchOn 8/30/06, John Fouhy [EMAIL PROTECTED] wrote: On 31/08/06, Amadeo Bellotti [EMAIL PROTECTED] wrote: first of all i have random.randint imported as rand like this: from random import randint as rand it is giving me an error at the line space = rand(1,82) the error its giving me is Traceback (most recent call last): File sudoku.py, line 1050, in ? space = rand(1,82) TypeError: 'int' object is not callable It's telling you that rand is an int.Since it didn't start offlike that, I suspect you have assigned to rand somewhere.Have a look through your code; are there any lines starting with: rand =?Also, in my opinion, it's a bad idea to rename standard libraryfunctions like that.If another python programmer looked at yourcode, they would probably be familiar with randint and understand what it does, but they won't know exactly what rand does without lookingthrough the rest of your code.--John. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] File IO
i do and they have writing but its just not printing it at allOn 8/29/06, Kent Johnson [EMAIL PROTECTED] wrote: Amadeo Bellotti wrote: Ok im trying to create a file that the user chooses the name of and print a varible that is a string to the text file. but for some reason whne i do this code: FILE = open(filename, w) FILE.write(puzzleanswers) FILE.close() it doesnt write anything does anyone know how to fix itso it works? I wouldprint filenameprint puzzleanswersto make sure you know what should happen.Kent___Tutor maillist- Tutor@python.orghttp://mail.python.org/mailman/listinfo/tutor ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] File IO
well i made a typo and puzzleanswers was empty i fixed it and it works fine thank you guys so muchOn 8/29/06, Bob Gailer [EMAIL PROTECTED] wrote:Amadeo Bellotti wrote: Ok im trying to create a file that the user chooses the name of and print a varible that is a string to the text file. but for some reason whne i do this code: FILE = open(filename, w) FILE.write(puzzleanswers) FILE.close() it doesnt write anythingThat could mean you get an empty file or you don't see the file. Whichis it?If the file is empty that means puzzleanswers isempty.If you don't see the file that means it is being written someplace other than where you are looking.--Bob Gailer510-978-4454 ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] File IO
no no the file shows up in the same directory as the .py file and i no it works cause i read the text fileOn 8/29/06, Alan Gauld [EMAIL PROTECTED] wrote:i do and they have writing but its just not printing it at all How do you know? Where are you looking for the file?Are you sure its not a Path issue?Alan G. On 8/29/06, Kent Johnson [EMAIL PROTECTED] wrote: Amadeo Bellotti wrote: Ok im trying to create a file that the user chooses the name of and print a varible that is a string to the text file. but for some reason whne i do this code: FILE = open(filename, w) FILE.write(puzzleanswers) FILE.close() it doesnt write anything does anyone know how to fix itso it works? I would print filename print puzzleanswers to make sure you know what should happen. Kent ___ Tutor maillist-Tutor@python.org http://mail.python.org/mailman/listinfo/tutor ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] A list of ints to a strings
I need to convert a list of intgers to a string so for example I have this x = [1, 2, 3, 4, 5, 6] I want this x = 1 2 3 4 5 6 I need this to write it to a .txt file does anyone know how to do this? ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] A list of ints to a strings
thank you and like wat if i wanna write one string on one line and another string on another line ect.On 8/25/06, David Heiser [EMAIL PROTECTED] wrote: This will work x = [1, 2, 3, 4, 5, 6] x = str(x)[1:-1].replace(,, '') open(filename.txt, w).write(x) -Original Message-From: [EMAIL PROTECTED] [mailto: [EMAIL PROTECTED]] On Behalf Of Amadeo BellottiSent: Friday, August 25, 2006 3:28 PMTo: TutorSubject: [Tutor] A list of ints to a stringsI need to convert a list of intgers to a string so for exampleI have thisx = [1, 2, 3, 4, 5, 6]I want thisx = 1 2 3 4 5 6I need this to write it to a .txt file does anyone know how to do this? ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] 2D array question [was (no subject)]
thank you so much Mr. Gauld that really helpedOn 8/18/06, Alan Gauld [EMAIL PROTECTED] wrote: Mr. Kuhlman it says python is not configured for tk.Gaarrgh! Why do linux distros do this? Stooopid... You will need to fetch another version of Python withTk support built in. Its a compile time option so you caneither fetch the source an build it yourself or find a Susepackage with Tk support already selected. Its really stupid for Suse to do that, it only saves a tinyamount of space and means you can't run any programsbased on Tkinter... but on another note does anyone know how to make a 2d array? This should probably be a separate post.Also can you change the subject line in your posts so peoplecan fiind the thread easily. I've changed it on this one to pickup the 2D array issueA 2D array is just a table. There are several ways to do that in Python but the easiest is just a list of lists: Think of a chessgame as an example where the boars is represented byan 8x8 2D array:chessBoard = [[0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0], [0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0]]Now you can access the third row, 4th column with: chessBoard[2][3] # remember zero indexing!Is that clear?You can also use tuples similarly, or nested dictionaries.A lot will depend on the data you are storing and how youwant to access it. Finally you can create a Class with bespoke methods tomore closely model your problem, but the class will usauallyhave one of the above solutions internally anyhow!HTH.Alan GauldAuthor of the Learn to Program web site http://www.freenetpages.co.uk/hp/alan.gauld ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] (no subject)
Mr. Gauld I run it from termainal on GNOME and it says ** IDLE can't import Tkinter. Your Python may not be configured for Tk. ** and Yea I am Administrator this is my Home computer after all im only 15.On 8/18/06, Alan Gauld [EMAIL PROTECTED] wrote: thank you but IDLE doesnt seem to work on Suse 9.2 do you know a way to fix it?I've only used IDLE on Linux a few times but it certainly workson RedHat, Mandriva and Slackware. And it used to work onSuse 5 - the only time I ever used Suse...What hapens when you try to run IDLE? It may just be a case of fixing a path setting or somesuch.Alan G. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] (no subject)
thank you Mr. Johnson this is my first program so its a little sloppy. I'm using gedit ill check out the other editors that u have thank youOn 8/17/06, Kent Johnson [EMAIL PROTECTED] wrote: Amadeo Bellotti wrote: Mr. Johnson i was hoping i didnt have to make my whole program into a loop because its about 900 lines of code and tabbing that would take a long timeIf your whole program is 900 lines without a subroutine then you havemore problems than just tabbing...really, a program this big should have many functions to divide up the work. Looking for a workaround for poorprogram structure is not a good solution in the long run; fixing theprogram structure so it is workable is a better idea.As a practical matter, many editors allow you to select and indent a block, including TextPad and Eclipse, the two editors I usually use.KentPS please reply to the list, not to me personally. On 8/17/06, *Kent Johnson* [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] wrote: Amadeo Bellotti wrote: hello is there a way if a condition is not met to restart the whole program? for example if and if statement returns true then re start the whole program? You can probably achieve what you want just by structuring the program correctly. My guess you need to use nested loops, something like this: while True: initialize_everything() while True: if something_is_wrong(): break do_some_work() This will do_some_work() until something_is_wrong(), then it will initialize_everything() and try again. If the test for something_is_wrong() is buried deep in the code you can break the loop by raising an exception which you catch in the top-level loop. Kent ___ Tutor maillist-Tutor@python.org mailto:Tutor@python.org http://mail.python.org/mailman/listinfo/tutor http://mail.python.org/mailman/listinfo/tutor___ Tutor maillist-Tutor@python.orghttp://mail.python.org/mailman/listinfo/tutor ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] (no subject)
Thank you again i no im a newbie and really inexperianced but thank youOn 8/17/06, Danny Yoo [EMAIL PROTECTED] wrote: thank you Mr. Johnson this is my first program so its a little sloppy. I'm using gedit ill check out the other editors that u have thank youMore fundamentally, spend some time to learn about functions; they'lladdress much of the original concerns you had.See any of the tutorials on: http://wiki.python.org/moin/BeginnersGuide/NonProgrammersand almost all of them should talk about what functions are, and how to use them.Best of wishes! ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] (no subject)
thank you again but i think i found a way to fix itOn 8/17/06, Danny Yoo [EMAIL PROTECTED] wrote: Mr. Yoo im working on a program to write a sudoku puzzle and if something is wrong with the last row i need to re make the whole puzzle over again. Here's a separate question that's related to the first: can you write a function that asks the user to enter a word, and continues prompting until the user enters a non-empty word?Hi Amadeo, Yes I can Mr. Yoo, but i dont really want to make my whole program a loop.Ok.Why not?I'm curious: is there a particular constraint you're trying to work under, or is it something else?Also, I'm not sure what you mean by whole program.In any case, here's a way to do it without an explicit 'for' or 'while'loop: def ask_for_input(): msg = raw_input(enter a word:) if msg: return msg else: return ask_for_input()This would not be the idiomatic way to do this in Python only because of a technical limitation in the main Python implementation (it doesn't supporttail call optimization).Still, would this be more acceptable to you, or do you also consider thisa loop? (Personally, I do. *grin*) ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Which Book
A good book is Practical Python by Magnus Lie Hetland.On 8/17/06, Alan Gauld [EMAIL PROTECTED] wrote: I have very little programming experience, I have decided to learn Python..there are tons of material and references on the web-pages, can you guys please suggest what is the best way to start or which ONE book which I should follow to start.Despite the fact that my tutor is available in paper form I personally don't recommend buying a beginners book - -they quickly becomeredundant so they are poor value. I would advocate working throughthe web tutorials (mine if you like:-) and then buy a goood referencebook (or two). Maybe a general treference like Python in a Nutshell plus maybe a specialised one in the areas you are interested in(Networks, Databases, Web, GUI, text processing etc)But tastes in books is so subjective its hard to give recommendations.I like generalist books like Programming Python, but many people don't like that one at all. I didn't particularly like Text ProcessinginPython, even though its the best book in its class - but I just didn'tlike the style much. But I know others who think its a bit of a masterpiece...A lot will depend on your previoius experience too.For example if you can already program in another language andhave a fair grasp of computer science terminology then my bookwould be a complete waste of time, but if you only have ac minimal experience and don;t know the CS terms my book would be a goodchoice (he says immodestly!)Best thing if possible is to borrow a copy (from a friend or library)or if there is a web version read a bit there first. HTH,Alan GauldAuthor of the Learn to Program web sitehttp://www.freenetpages.co.uk/hp/alan.gauld___ Tutor maillist-Tutor@python.orghttp://mail.python.org/mailman/listinfo/tutor ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] (no subject)
thank you but IDLE doesnt seem to work on Suse 9.2 do you know a way to fix it?On 8/17/06, Alan Gauld [EMAIL PROTECTED] wrote: thank you Mr. Johnson this is my first program so its a little sloppy. I'm using gedit ill check out the other editors that u have thank youIf you have Python you will have either IDLE or Pythonwin (or both)Both of these will allow block indent/unindent so simply load the code into IDLE to do the indentation.. You can go back to geditafterwards if you like.But as Kent said you should ideally aimto write the code asfunctions, each about 5-50 lines long (less than 5 and the advantage is minimal, mor than 50 is just too long - around 12 lines perfunctoionis a good average IMHOBut don't use number of lines as the deciding factor! Divide the codeinto blocks of code that do something logical that you can describe in a few words (see the comments from Danny to Kermit for examples!)Use those few words to name the function. Consider how to pass keydata between the funbctions using parameters and return values.If you don't know how to write functions take a look at the Functions topic of my tutor.HTH,Alan GauldAuthor of the Learn to Program web sitehttp://www.freenetpages.co.uk/hp/alan.gauld ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] (no subject)
Mr. Kuhlman it says python is not configured for tk. but on another note does anyone know how to make a 2d array? On 8/18/06, John Fouhy [EMAIL PROTECTED] wrote: On 18/08/06, Amadeo Bellotti [EMAIL PROTECTED] wrote: thank you but IDLE doesnt seem to work on Suse 9.2 do you know a way to fix it?Why not -- what goes wrong?Is there an error message? --John. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] (no subject)
hello is there a way if a condition is not met to restart the whole program? for example if and if statement returns true then re start the whole program? ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor