Thank you Dax! That was it! Now I can run the script. Cheers, Bulent
On Mon, Dec 12, 2011 at 12:57 PM, <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. Running a script! (Bulent Arikan) > 2. Re: Running a script! (David Smith) > 3. Re: best book for OOP (wesley chun) > 4. Visual and audible system bell (David Smith) > 5. Re: Visual and audible system bell (Alan Gauld) > 6. Re: best book for OOP (Sarma Tangirala) > 7. Re: (no subject) (Hugo Arts) > > > ---------------------------------------------------------------------- > > Message: 1 > Date: Mon, 12 Dec 2011 08:00:51 +0200 > From: Bulent Arikan <bulent.ari...@gmail.com> > To: tutor@python.org > Subject: [Tutor] Running a script! > Message-ID: > <caa5wl0g0ttniaqcg0wzx70783bi60baxm__etbtwhcpnq+n...@mail.gmail.com > > > Content-Type: text/plain; charset="windows-1252" > > Dear List, > > I am an absolute beginner to programming and Python. I have Python 2.6.5 > and 3.2 running on Mac OS 10.6.8 Snow Leopard. I have self-help books but > the problem I am having is not described in any of them. The answer may be > too obvious though. I am using IDLE: I figured that I could call Idle by > typing its name on the Terminal instead of launching it from the > Applications ?WOW! big step ;)) When I save a script as (.py) document, I > do not know how to 'run' it since the IDLE (2.6 or 3.2) menus do not have > RUN option (as they describe in the books I have). I understand that I may > have to type a command to run the script on the Terminal but I could not > find a specific command. It also seemed strange to me that there was not a > shortcut in Mac OS to run scripts unlike Windows. > > Thank you for your time and help, > > -- > B?LENT > -------------- next part -------------- > An HTML attachment was scrubbed... > URL: < > http://mail.python.org/pipermail/tutor/attachments/20111212/c0d85f7e/attachment-0001.html > > > > ------------------------------ > > Message: 2 > Date: Mon, 12 Dec 2011 06:26:28 +0000 > From: David Smith <das.mm...@gmail.com> > To: tutor@python.org > Subject: Re: [Tutor] Running a script! > Message-ID: <6f440ed4-bc58-4310-b0c4-61dc48379...@gmail.com> > Content-Type: text/plain; charset=windows-1252 > > > If I have understood you correctly you are looking at the Python Shell. > > On this window choose File then New Window this will open a script window > albeit without any code. This window will have a Run menu and within this > menu there is a Run Module item which is what I think you are looking for. > I hope this helps. > > Dax > > On 12 Dec 2011, at 06:00, Bulent Arikan wrote: > > > Dear List, > > > > I am an absolute beginner to programming and Python. I have Python 2.6.5 > and 3.2 running on Mac OS 10.6.8 Snow Leopard. I have self-help books but > the problem I am having is not described in any of them. The answer may be > too obvious though. I am using IDLE: I figured that I could call Idle by > typing its name on the Terminal instead of launching it from the > Applications ?WOW! big step ;)) When I save a script as (.py) document, I > do not know how to 'run' it since the IDLE (2.6 or 3.2) menus do not have > RUN option (as they describe in the books I have). I understand that I may > have to type a command to run the script on the Terminal but I could not > find a specific command. It also seemed strange to me that there was not a > shortcut in Mac OS to run scripts unlike Windows. > > > > Thank you for your time and help, > > > > -- > > B?LENT > > _______________________________________________ > > Tutor maillist - Tutor@python.org > > To unsubscribe or change subscription options: > > http://mail.python.org/mailman/listinfo/tutor > > > > ------------------------------ > > Message: 3 > Date: Sun, 11 Dec 2011 22:54:50 -0800 > From: wesley chun <wes...@gmail.com> > To: surya k <sur...@live.com> > Cc: Python Tutor <tutor@python.org> > Subject: Re: [Tutor] best book for OOP > Message-ID: > <cab6eaa5zb_cnrpxpwh2mr4jnc7omqfveye6exi54edqcjyf...@mail.gmail.com > > > Content-Type: text/plain; charset=ISO-8859-1 > > what do you think you are missing? is there something in the book that > you don't/can't understand? those of us on the list may be able to > help you out... sometimes humans are better at explaining things than > just books. :-) > > best regards, > --wesley > > > > On Sun, Dec 11, 2011 at 6:49 AM, surya k <sur...@live.com> wrote: > > > > I'm reading "Core Python Programming" - Chun.. > > Currently, I am studying OOP in it.. and I feel there is something I am > missing in that while studying. Actually I am from C.. so, no idea of OOP. > > Could you tell me the best, simple, easy to understand book!! > > > -- > - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - > "Python Web Development with Django", Addison Wesley, (c) 2009 > ? ? http://withdjango.com > > wesley.chun : wescpy-gmail.com : @wescpy/+wescpy > python training and technical consulting > cyberweb.consulting : silicon valley, ca > http://cyberwebconsulting.com > > > ------------------------------ > > Message: 4 > Date: Mon, 12 Dec 2011 07:57:16 +0000 > From: David Smith <das.mm...@gmail.com> > To: tutor@python.org > Subject: [Tutor] Visual and audible system bell > Message-ID: <e9203ab3-fab5-4c00-ba18-551fafa51...@gmail.com> > Content-Type: text/plain; charset=us-ascii > > Dear list > > In a terminal window > > python3.2 > > at the command gives me > > Python 3.2 (r32:88452, Feb 20 2011, 11:12:31) > [GCC 4.2.1 (Apple Inc. build 5664)] on darwin > Type "help", "copyright", "credits" or "license" for more information. > >>> > > then > > >>>> print ("\a") > > triggers a visual and audible bell as set in Terminal window preferences. > > However > > >>>> print ("\a") > > and pressing Enter in a Python Shell window > > or including > > print ("\a") > input ("\n\nPress the enter key to exit.") > > results in neither a visible nor an audible system bell. > > Any suggestions? > > Mac OS X 10.7.2 > Terminal 2.2.1(299) > Python 3.2 > Tk 8.5 > > Dax > > > > > > ------------------------------ > > Message: 5 > Date: Mon, 12 Dec 2011 08:18:51 +0000 > From: Alan Gauld <alan.ga...@btinternet.com> > To: tutor@python.org > Subject: Re: [Tutor] Visual and audible system bell > Message-ID: <jc4ddb$kgr$1...@dough.gmane.org> > Content-Type: text/plain; charset=ISO-8859-1; format=flowed > > On 12/12/11 07:57, David Smith wrote: > > > In a terminal window > >>>>> print ("\a") > > > > triggers a visual and audible bell as set in Terminal window preferences. > > > > However > > > >>>>> print ("\a") > > and pressing Enter in a Python Shell window > > results in neither a visible nor an audible system bell. > > I assume the second case means an IDLE window? > If so then its not surprising because IDLE does not use the Terminal > settings. It is its own Terminal. And IDLE intercepts many of the > standard control keys etc. In general this is a good thing since IDLE is > trying to make debugging and testing code as easy as possible so it > prevents premature exit from IDLE. But occasionally it stops things > happening the way you want. In this case no bell. (It is worth perusing > the IDLE config settings, it may be possible to change this, but I > suspect its more deeply embedded in the code than that) > > The only way round it is probably to just test your code by running it > in a Terminal and just use IDLE for editing and debugging. > > -- > Alan G > Author of the Learn to Program web site > http://www.alan-g.me.uk/ > > > > ------------------------------ > > Message: 6 > Date: Mon, 12 Dec 2011 14:16:08 +0530 > From: Sarma Tangirala <tvssarma.ome...@gmail.com> > To: Alan Gauld <alan.ga...@btinternet.com> > Cc: tutor@python.org > Subject: Re: [Tutor] best book for OOP > Message-ID: > <cabfckks-mkcudaotjnjurtluyxhjhpciw+9dyez7y0brknr...@mail.gmail.com > > > Content-Type: text/plain; charset="iso-8859-1" > > > Object Oriented Analysis and Design with Applications > > by Grady Booch (1st edition) > > Classic text on OO Design with code and case studies realized in 5 > different OOP languages (Smalltalk, Object Pascal, C++, Lisp, ADA) > > Explains why OOP is important and how to ise it effectively. Also > introsduces Booch's OOD notation which was paret of the core that evolved > into UML. > > > > +1 > Used this book in an OOAD course and was very good. > -------------- next part -------------- > An HTML attachment was scrubbed... > URL: < > http://mail.python.org/pipermail/tutor/attachments/20111212/eac5f1e9/attachment-0001.html > > > > ------------------------------ > > Message: 7 > Date: Mon, 12 Dec 2011 11:56:36 +0100 > From: Hugo Arts <hugo.yo...@gmail.com> > To: shawn taylor <sht...@yahoo.com> > Cc: *tutor python <tutor@python.org> > Subject: Re: [Tutor] (no subject) > Message-ID: > <CAJmBOf=Qez_qfC+F-mJfx1Ob=gvfjzuhbrcntgxwvoowzmu...@mail.gmail.com > > > Content-Type: text/plain; charset=UTF-8 > > On Mon, Dec 12, 2011 at 3:56 AM, shawn taylor <sht...@yahoo.com> wrote: > > firstname = raw_input ("Enter your first name ") > > lastname = raw_input ("Enter your last name ") > > idnumber = raw_input ("Enter your id number ") > > birthday = raw_input ("Enter your birthday mm/dd/yyyy ") > > username1 = firstname[0] + lastname[0] + idnumber > > > > print ("Your username is ") + username1 > > > > midltr = firstname[len(firstname) / 2] > > midltrlastnm = lastname[len(lastname)??/ 2] > > > > on = int (birthday[0]) > > tw = int (birthday[1]) > > th = int (birthday[3]) > > fr = int (birthday[4]) > > fv = int (birthday[6]) > > sx = int (birthday[7]) > > sv = int (birthday[8]) > > eg = int (birthday[9]) > > > > num = str (on + tw + th + fr + fv + sx + sv + et) > > > > while num > 10: > > > > > > print num > > > > I'm trying to add all the digits in the birthday and keep adding till i > get > > a single digit and I'm stuck > > anything would help thanks > > alright, well, you've got all the basic ideas that you need in there, > it's just a matter of combining them in the right way. The basic > component is the while loop you have, you want to keep adding the > digits while there's more than two of them: > > while num > 10: > #add digits > > there is a slight error in there (what happens if the number comes out > to exactly ten? is that what should happen?), but I'll leave it in for > you to find. Another problem is that the while loop wants to check the > num variable, but it doesn't actually exist until the bottom of the > loop. What we do have at the top of the loop is the birthday variable, > but that has some pesky '/' characters in there that we don't really > want. I suggest the first thing you do is remove those slashes. (hint: > the str class has a replace() method. Google it and see if you can > figure out how to use it for this purpose). > > no_slashes_birthday = # use replace here in someway on the birthday? > num = int(no_slashes_birthday) > while num > 10: > #add digits > > that's enough for basic setup of the while loop. Now, to add the > digits. First thing we'll need to do is separate our number out into > digits. There's a nifty trick with the division and modulo operators > that can get us individual digits[1], but I don't want to convolute > the essence of this example with math. So here's a simpler way: leave > your number as a string! As you've already figured out, it's easy to > get characters in a string, and you can convert them to integers > individually again. > > Ok, so we don't do num = int(no_slashes_birthday), but just num = > no_slashes_birthday. Now we can get at the digits. All we need to do > now is convert them all into integers and add them together inside the > loop, and the loop will repeat it as necessary. The general structure > is "for every digit in num, convert digit to integer and add digit to > total." If you learn to state problems in this way, the necessary code > should flow out from it almost automatically. We can already see that > we'll need a for loop here, and a variable called total with a > sensible starting value[2]. See if you can figure it out. > > We're almost done here. at the end of the loop we've got a variable > called total, with our added digits. But the point of a loop is to run > multiple times, and our loop wants to have this total in a variable > called num, and it wants it to be a string so we can get at the > individual digits again. So we want to take the integer from total, > convert it back to a string, and put it in the num variable, right at > the end of the loop. That way it can run over and over until we have > only one digit left: > > no_slashes_birthday = # use replace here in someway on the birthday? > num = no_slashes_birthday > while num > 10: > # for every digit, convert digit to int and add to total > # convert total back to string and put it in num for the next iteration > > if you fill in the blanks you'll be almost done. There is one problem > though, and it's in the condition of the while loop. The statement > "while num > 10" makes no sense at all, because num, despite its name, > is not a number but a string. Now *we* know that there are characters > representing a number inside the string, but the computer doesn't care > which characters represent a number and it shouldn't, because you've > chosen to store it as a string. So for all it cares you might as well > be asking if "hello" > 10, which very obviously doesn't make sense. > See if you can find a way around this (hint: the requirement was "keep > going while we have more than 1 digit." strings can't be compared to > numbers, but they do have a length). > > And with that, you should be able to get it working. Good luck, and if > you have any trouble come back here. > > Hugo > > P.S.: I wrote this as soon as I woke up. Hopefully this reaches you in > time for you finals, though I fear the worst. In any case, (stating > the obvious) it might be a good idea to start studying a little > earlier next time ;) Programming isn't learned in a day. > > > ------------------------------ > > _______________________________________________ > Tutor maillist - Tutor@python.org > http://mail.python.org/mailman/listinfo/tutor > > > End of Tutor Digest, Vol 94, Issue 44 > ************************************* > -- BÜLENT ARIKAN, PhD Senior Research Fellow Research Center for Anatolian Civilizations Koç University İstiklal Caddesi No: 181 Merkez Han Beyoğlu - ISTANBUL TURKEY 34433 (+ 90) 212-393-6036
_______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor