Re: [Tutor] Tutor Digest, Vol 117, Issue 28
; > caosa8feqwpekkyof9u69niur8dut-kj-2fkxdl0kyhtp2-h...@mail.gmail.com> > Content-Type: text/plain; charset="iso-8859-1" > > def main(): > > goal, apr, deposit = getSavingsDetails() > determineMonthsTilSaved( goal, apr, deposit ) > > months = determineMonthsTilSaved(goal, apr, deposit) > > summarize( months ) > > def getSavingsDetails(): > """ > goal = float( input( "Principal sought? $" ) ) > apr = float( input( "Interest rate? " ) ) > deposit = float( input( "Deposit? $" ) ) > """ > goal = 1000.0 > apr = .05 > deposit = 100 > return goal, apr, deposit > > def determineMonthsTilSaved( goal, apr, deposit ): > months = 0 > saved = 0 > totalInterest = 0.0 > > > > > while saved < goal: > interest = saved * apr / 12 > totalInterest += interest > saved += (deposit + interest) > months += 1 > print( months, ("%.2f" % saved), ("%.2f" % totalInterest) ) > > return months > > def summarize( months ): > print( "Saved! It took ", months // 12, "years and", months % 12, > "months." ) > > main() > > > When this is run it appears that determineMonthsTilSaved is running twice > before the loop ends. It is supposed to run until saved > than goal, but > look at the output. It runs again even after saved > goal. Help please? > -- next part -- > An HTML attachment was scrubbed... > URL: < > http://mail.python.org/pipermail/tutor/attachments/20131116/26f2f3b0/attachment.html > > > > -- > > Subject: Digest Footer > > ___ > Tutor maillist - Tutor@python.org > https://mail.python.org/mailman/listinfo/tutor > > > -- > > End of Tutor Digest, Vol 117, Issue 28 > ** > -- Warm regards. Satheesan Varier 860 (970) 2732 ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Tutor Digest, Vol 117, Issue 32 ( Subject: Phython List values )
Message: 7 Date: Mon, 18 Nov 2013 06:57:20 - From: "Ayo Rotibi" To: Subject: [Tutor] Phython List values Message-ID: <002901cee42b$6e346fe0$4a9d4fa0$@com> Content-Type: text/plain; charset="us-ascii" Hi, I am a complete newbie to python. I read that an assignment with an = on lists does not make a copy. Instead, assignment makes the two variables point to the one list in memory. For instance, if a = [1, 2, 3] and b=a, then b = [1, 2, 3]. However, I discovered that if I change the value in 'a', 'b' does not take the new value. I thought since it is pointing to the same storage as 'a', 'b' should take the new value. Any explanation would be appreciated. Dear Ayo :: You should look at the order of execution: >>> a=['a','b','c'] >>> b=a >>> b.append('d') >>> a ['a', 'b', 'c', 'd'] In your third step you reassigned b=['a','b','c'] Best wishes ! _ Desire, Dedication, Determination and a little bit of Talent On Mon, Nov 18, 2013 at 5:35 AM, wrote: > Send Tutor mailing list submissions to > tutor@python.org > > To subscribe or unsubscribe via the World Wide Web, visit > https://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. Call Attribute error - Was Re: Tutor Digest, Vol 117,Issue > 28 (Alan Gauld) >2. Re: Link required for difference between class and object > (Joel Goldstick) >3. Re: Link required for difference between class and object > (Mark Lawrence) >4. Re: basic function concept (Alex Kleider) >5. Re: basic function concept (Alex Kleider) >6. Re: Link required for difference between class and object > (Alan Gauld) >7. Phython List values (Ayo Rotibi) > > > ---------- > > Message: 1 > Date: Sun, 17 Nov 2013 15:23:06 + > From: Alan Gauld > To: tutor@python.org > Subject: [Tutor] Call Attribute error - Was Re: Tutor Digest, Vol > 117,Issue 28 > Message-ID: > Content-Type: text/plain; charset=ISO-8859-1; format=flowed > > On 17/11/13 12:19, Satheesan Varier wrote: > > class myclass(): > > def test(self): > > print "print this line" > > > > if __name__ == '__main__': > >myclass.run() > > > > You can do the test run with an instance of that class, as follows: > > > > >>> k=myclass() > > > > >>> myclass.test(k) > > print this line > > Or more conventionally > > k.test() > > Please don't post the entire digest when replying, remove any irrelevant > material. Some people pay by the byte and don't > want to pay for stuff they've already seen. > > > -- > Alan G > Author of the Learn to Program web site > http://www.alan-g.me.uk/ > http://www.flickr.com/photos/alangauldphotos > > > > -- > > Message: 2 > Date: Sun, 17 Nov 2013 10:29:48 -0500 > From: Joel Goldstick > To: Reuben > Cc: "tutor@python.org" > Subject: Re: [Tutor] Link required for difference between class and > object > Message-ID: > < > capm-o+xxzuie_us8rj3txn2vu-fzi__3obsjcwgybdsqete...@mail.gmail.com> > Content-Type: text/plain; charset=UTF-8 > > On Sun, Nov 17, 2013 at 7:24 AM, Reuben wrote: > > Hi All, > > > > It would be nice if someone could forward a link which explains classes > and > > object. > > I am still struggling to understand classes and objects better. > > > > Regards, > > Reuben > > > > ___ > > Tutor maillist - Tutor@python.org > > To unsubscribe or change subscription options: > > https://mail.python.org/mailman/listinfo/tutor > > > > Have you looked here yet? http://docs.python.org/2/tutorial/classes.html > > -- > Joel Goldstick > http://joelgoldstick.com > > > -- > > Message: 3 > Date: Sun, 17 Nov 2013 15:53:49 + > From: Mark Lawrence > To: tutor@python.org > Subject: Re: [Tutor] Link required for difference
Re: [Tutor] Tutor Digest, Vol 117, Issue 33[ Re: Ideas ? ]
Need a little help with finding a process for this: when a string of text is input, for example: abc def. I want to have each letter shift to the right one place in the alphabet. Thus.. abc def would be output as bcd efg. Any ideas on how to do this? - if you do not want to use the translate: >>> s='abcdef ghijk lmn' >>> k='' >>> for char in s: if char!=' ': k+=str(chr(ord(char)+1)) else: k+=' ' >>> k 'bcdefg hijkl mno' -- If you want to use translate: >>> from string import maketrans >>> your_alphabets = 'abcdefghijklmnopurstuvwzyz' >>> my_alphabets='bcdefghijklmnopqystuvwxyza' >>> s='Let us Test Your language !' >>> s.translate(maketrans(your_alphabets, my_alphabets)) 'Lfu vt Tftu Ypvs mbohvbhf !' Note: my_alphabets to fine tune __ On Mon, Nov 18, 2013 at 6:00 AM, wrote: > Send Tutor mailing list submissions to > tutor@python.org > > To subscribe or unsubscribe via the World Wide Web, visit > https://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. ideas? (Byron Ruffin) >2. Re: Phython List values :p: (Paradox) > > > -- > > Message: 1 > Date: Sun, 17 Nov 2013 21:27:56 -0600 > From: Byron Ruffin > To: tutor@python.org > Subject: [Tutor] ideas? > Message-ID: > kojukeyg+c...@mail.gmail.com> > Content-Type: text/plain; charset="iso-8859-1" > > Need a little help with finding a process for this: > > when a string of text is input, for example: abc def. > I want to have each letter shift to the right one place in the alphabet. > Thus.. > abc def would be output as bcd efg. > > Any ideas on how to do this? > -- next part -- > An HTML attachment was scrubbed... > URL: < > http://mail.python.org/pipermail/tutor/attachments/20131117/56728ee8/attachment-0001.html > > > > -- > > Message: 2 > Date: Mon, 18 Nov 2013 05:49:06 -0500 > From: Paradox > To: tutor@python.org > Subject: Re: [Tutor] Phython List values :p: > Message-ID: <5289f0a2.3010...@pobox.com> > Content-Type: text/plain; charset=windows-1252; format=flowed > > Ayo, > > On 11/18/2013 01:57 AM, Ayo Rotibi wrote: > > > > > > I read that an assignment with an = on lists does not make a copy. > > Instead, assignment makes the two variables point to the one list in > > memory. For instance, if a = [1, 2, 3] and b=a, then b = [1, 2, 3]. > > > > However, I discovered that if I change the value in ?a?, ?b? does not > > take the new value. I thought since it is pointing to the same > > storage as ?a?, ?b? should take the new value? > > > > > It is not clear to me what code you are running, maybe you could give us > the specifics? When I run an assignment like you seem to be talking > about I get the expected result (using ipython for an interactive > session to demonstrate): > > In [1]: a=[1,2,3] > > In [2]: b=a > > In [3]: b > Out[3]: [1, 2, 3] > > In [4]: a[1]=0 > > In [5]: a > Out[5]: [1, 0, 3] > > In [6]: b > Out[6]: [1, 0, 3] > > Is that not what you are seeing? If not perhaps you could show us how > you are doing the list assignment and changing the list a, what output > you are expecting and what output you are getting. > > thomas > > > -- > > Subject: Digest Footer > > ___ > Tutor maillist - Tutor@python.org > https://mail.python.org/mailman/listinfo/tutor > > > -- > > End of Tutor Digest, Vol 117, Issue 33 > ** > -- Warm regards. Satheesan Varier 860 (970) 2732 ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] raw input program is still running.
table, a second line with the total number of rows (atoms) in the table > > followed by a line with the ordered string of chemical symbols separated > > by a silgle space. > > > > My aim is load the numerical data from this file to a c++ program to > > process this information. > > > > Thanks in advance. > > > > -Ruben. > > > > I'm sorry but we don't write code for you here. I suggest that you > start out by reading the tutorial here > http://docs.python.org/3/tutorial/index.html, try writing something and > when and if you run into problems please feel free to get back to us. > > -- > Python is the second best programming language in the world. > But the best has yet to be invented. Christian Tismer > > Mark Lawrence > > > > -- > > Message: 6 > Date: Sat, 23 Nov 2013 03:19:46 +0200 > From: Davnobezimeni Sasha Balagura > To: tutor@python.org > Subject: [Tutor] Using tkinter::ttk::treeview to implement data view. > Message-ID: > < > caa7ixku8_kd9wsn+8xfqrfu9yhdmobgq1kxasn7fhxpt5ic...@mail.gmail.com> > Content-Type: text/plain; charset="iso-8859-1" > > Hello. > I have to implement parcer for .txt file with special formating. There are > a lot of data to display, modify, add. I decided to use > tkinter::ttk:treeviev for this. And it really good one, very fast and good > looking..but.. > But I cant set borders between cells, like in Excel. Is it real at all for > this widget? Or i've just overlooked something? > > Best regards, > Alex > -- next part -- > An HTML attachment was scrubbed... > URL: < > http://mail.python.org/pipermail/tutor/attachments/20131123/0599771c/attachment-0001.html > > > > -- > > Message: 7 > Date: Fri, 22 Nov 2013 16:08:25 -0600 > From: Paul Steele > To: tutor@python.org > Subject: [Tutor] numrows returning -1 > Message-ID: > < > cald6m00nu1usqd0oderb4sqtpwidinqrzwwxn15uudptax4...@mail.gmail.com> > Content-Type: text/plain; charset="iso-8859-1" > > Hey all... > > I am getting a numrows count of -1 when I print numrows (see line 23 of the > code). What does "-1" mean?I think my connection is working and my > table has data. > > Here's my code... > > #!/usr/bin/python > # -*- coding: utf-8 -*- > > import mysql.connector > from mysql.connector import errorcode > > try: > con = mysql.connector.connect(user='root', password='pw848596', > host='127.0.0.1', > database='mydb') > except mysql.connector.Error as err: > if err.errno == errorcode.ER_ACCESS_DENIED_ERROR: > print("Something is wrong with your user name or password") > elif err.errno == errorcode.ER_BAD_DB_ERROR: > print("Database does not exists") > else: > print(err) > else: > cur=con.cursor() > > cur.execute("select Name from Rosters") > numrows = cur.rowcount > print numrows > for x in xrange(0,numrows): > row = cursor.fetchone() > print "Name" > > con.close() > -- next part -- > An HTML attachment was scrubbed... > URL: < > http://mail.python.org/pipermail/tutor/attachments/20131122/bf7c39de/attachment.html > > > > -- > > Subject: Digest Footer > > ___ > Tutor maillist - Tutor@python.org > https://mail.python.org/mailman/listinfo/tutor > > > -- > > End of Tutor Digest, Vol 117, Issue 44 > ** > -- Warm regards. Satheesan Varier 860 (970) 2732 ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor