Re: [Tutor] Tutor Digest, Vol 106, Issue 74
Sorry, I should have been more clear in what I was trying to accomplish. I am trying to build the latin square as follows: 1234567 2345671 3456712 4567123 5671234 6712345 7123456 So, the scaleorder is the n*n scale of the square - in this case, a 7x7. The key is that there should be no duplicate number for each row and for each column. And the topleft variable is the number in the topleft that sets how the rest of the square will look - in the example I gave above, it is 1. The link below is the original exercise - I am not in school, purely for my own education as I am really trying hard to become a passable Python programmer. I've been working at it for 6 month now, and I don't know any other languages: http://www.cse.msu.edu/~cse231/PracticeOfComputingUsingPython/02_Control/LatinSquares/Project03.pdf Thank you, Brandon On Mon, Dec 31, 2012 at 3:00 AM, tutor-requ...@python.org wrote: Send Tutor mailing list submissions to tutor@python.org To subscribe or unsubscribe via the World Wide Web, visit http://mail.python.org/mailman/listinfo/tutor or, via email, send a message with subject or body 'help' to tutor-requ...@python.org You can reach the person managing the list at tutor-ow...@python.org When replying, please edit your Subject line so it is more specific than Re: Contents of Tutor digest... Today's Topics: 1. Re: help (Mike G) 2. another for loop question - latin square (Brandon Merritt) 3. Re: another for loop question - latin square (Steven D'Aprano) 4. Re: another for loop question - latin square (Dave Angel) 5. Re: another for loop question - latin square (Mitya Sirenef) 6. Re: another for loop question - latin square (Alan Gauld) -- Message: 1 Date: Sun, 30 Dec 2012 04:30:21 -0800 From: Mike G msg@gmail.com To: tutor@python.org Subject: Re: [Tutor] help Message-ID: CAHD43mpeT44WytjM= pqyxqp14vg608u5ry-6nr2fy-x6m1-...@mail.gmail.com Content-Type: text/plain; charset=ISO-8859-1 Hi Randy I am an older newbie teaching myself Python programming. Me too :) My problem is I hear no system bell; the enter doesn't respond by quitting the program; The problem with the program code the enter key hasn't worked in earlier programs. I appreciate any advice I may recieve with this coding glitch. I copied the code into a blank .py file and ran it from cmd in Windows XP x86 using Python 273, it worked fine - including the beep. As well, hitting Enter exited the program. It sounds like (no pun intended) it may be how you're running the program. I would use a py file and run it using cmd - holler if you need help, you may if the path to Python isn't good to go. Mike -- Message: 2 Date: Sun, 30 Dec 2012 15:59:14 -0800 From: Brandon Merritt merrit...@gmail.com To: tutor@python.org Subject: [Tutor] another for loop question - latin square Message-ID: caehlphwnwwz82bv52m3bpbbyoqjtpfvxn2wulbsio_t3cmn...@mail.gmail.com Content-Type: text/plain; charset=iso-8859-1 I am having trouble figuring out a solution after a couple hours now of playing with the code. I'm trying to make a latin square using the code below: scaleorder = int(raw_input('Please enter a number for an n*n square: ')) topleft = int(raw_input('Please enter the top left number for the square: ')) firstrow = range((topleft),scaleorder+1) count = 0 while count 8: for i in firstrow: print i count += 1 firstrow[i+1] --- It seemed like I could make the for loop work by doing something like this: for i in firstrow: print i, i+2 but that obviously is not a solution either. Any ideas? Thanks, Brandon -- next part -- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/tutor/attachments/20121230/0d206b45/attachment-0001.html -- Message: 3 Date: Mon, 31 Dec 2012 11:27:22 +1100 From: Steven D'Aprano st...@pearwood.info To: tutor@python.org Subject: Re: [Tutor] another for loop question - latin square Message-ID: 50e0dbea.5060...@pearwood.info Content-Type: text/plain; charset=UTF-8; format=flowed On 31/12/12 10:59, Brandon Merritt wrote: I am having trouble figuring out a solution after a couple hours now of playing with the code. I'm trying to make a latin square using the code below: scaleorder = int(raw_input('Please enter a number for an n*n square: ')) topleft = int(raw_input('Please enter the top left number for the square: ')) firstrow = range((topleft),scaleorder+1) count = 0 while count 8: for i in firstrow: print i count += 1 firstrow[i+1] ---
[Tutor] Please help
I do not understand my error (it says something about an out-of-function return on line 179) my code is at the link http://www.mediafire.com/download.php?4ga0weu4ifc6s1u___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] another for loop question - latin square (was: Tutor Digest, Vol 106, Issue 74)
On 01/01/2013 08:27 PM, Brandon Merritt wrote: Sorry, I should have been more clear in what I was trying to accomplish. I am trying to build the latin square as follows: 1234567 2345671 3456712 4567123 5671234 6712345 7123456 So, the scaleorder is the n*n scale of the square - in this case, a 7x7. The key is that there should be no duplicate number for each row and for each column. And the topleft variable is the number in the topleft that sets how the rest of the square will look - in the example I gave above, it is 1. The link below is the original exercise - I am not in school, purely for my own education as I am really trying hard to become a passable Python programmer. I've been working at it for 6 month now, and I don't know any other languages: http://www.cse.msu.edu/~cse231/PracticeOfComputingUsingPython/02_Control/LatinSquares/Project03.pdf Thank you, Brandon Please reply to a single message, not to some digest. This way your new message will be threaded together with the previous ones. And for those unable to see the threads, at least the subject line will match. Note the first line below of the quote you used: On Mon, Dec 31, 2012 at 3:00 AM, tutor-requ...@python.org wrote: snip When replying, please edit your Subject line so it is more specific than Re: Contents of Tutor digest... So you don't just want a latin-square, you want a particular one. You picked the most trivial one, where all the spots are numeric, and each line is simply sequentially chosen from a ring, 1 through scaleorder. Assuming scaleorder is less than 10, the following should work. table = [str(i) for i in range(1, scaleorder+1) * 3] for row in range(topleft-1, topleft+scaleorder-1): line = table[row:row+scaleorder] print .join(line) If you have to deal with scaleorders bigger than 9, then you'll need a separator between the numbers. Probably the easiest place to fix that would be in constructing the table. But a qd fix might be to use .join() on the last line. -- DaveA ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Tutor Digest, Vol 106, Issue 74
Brandon, Please trim your response to only the parts of the email that are actually relevant. As given, you have duplicated SIX emails which we have already seen and don't need to see again, at least not in full, multiple hundreds of lines of text. Also, please ensure that you use a sensible, meaningful subject line. Re: [Tutor] Tutor Digest, Vol 106, Issue 74 means nothing. More below. On 02/01/13 12:27, Brandon Merritt wrote: Sorry, I should have been more clear in what I was trying to accomplish. I am trying to build the latin square as follows: 1234567 2345671 3456712 4567123 5671234 6712345 7123456 Right. So start off by writing down how you would do this in ordinary English: Step 1: Write down the list 1234567. Step 2: Take the digits above, move the first digit to the end, and write it down. Step 3: Repeat Step 2 five more times. (Six times in total.) Now try turning that into Python code. Good luck! -- Steven ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Please help
Jack Little wrote: I do not understand my error (it says something about an out-of-function return on line 179) my code is at the link http://www.mediafire.com/download.php?4ga0weu4ifc6s1u ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor I'd like to help, but I'm not going to download anything from that site. Can you instead post it on gist.github.com or bpaste.com? _Ryan ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Please help
On 02/01/13 13:02, Jack Little wrote: I do not understand my error (it says something about an out-of-function return on line 179) You cannot use return unless it is inside a function. # This is okay. def test(): print test return testing complete # indented, therefore inside the function # this is not okay def test(): print test return testing complete # not indented, therefore not inside the function -- Steven ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Please help
Maybe tomorrow I can just email you the code ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Please help
I saw the code; I see too many formatting errors: Line No 24 starts a function definition and the next few lines are indented by two spaces, but Line 29 is a print statement that is in line with the def; IOW it completes the function. It is very likely wrong. You are defining functions within functions; again it is very likely to be wrong. My advice, look at PEP 8 and also some sample python code in the tutorial to understand how to format code. Remember: Leading whitespace is syntactically significant HTH Asokan Pichai Religion offers hope against all the strife and misery of the world caused by religions. ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
[Tutor] HELP- Regarding working with python
Hi.. I am using python 2.7 and scikit-learn for machine learning. And OS is Windows 7. Wanna know how to import our own data sets in scikit-learn? Regards, Gayathri.S ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor