Re: [Tutor] unittests

2014-04-01 Thread Danny Yoo
> Yes, that unit test was written by Danny (I assume -- I suppose he might > have copied it from somewhere else.) Oh, who knows where I got that code from. :P --- Sydney, you can also take a look at some of the official documentation of the unittest library: https://docs.python.org/2/libra

Re: [Tutor] exercise (while loop)

2014-04-01 Thread Danny Yoo
> So this call will always try to round None(the default return value) > And of course it produces no output since it prints nothing. > > Are you sure that's actually what is in the book? No. That's very much why I wanted a reference to the original source of the problem. Scott attributed too m

Re: [Tutor] conditional execution

2014-04-01 Thread Zachary Ware
Hi Patti, On Tue, Apr 1, 2014 at 11:07 AM, Patti Scott wrote: > I've been cheating: comment out the conditional statement and adjust the > indents. But, how do I make my program run with if __name__ == 'main': > main() at the end? I thought I understood the idea to run a module called > directl

Re: [Tutor] conditional execution

2014-04-01 Thread Chris “Kwpolska” Warrick
On Tue, Apr 1, 2014 at 6:07 PM, Patti Scott wrote: > I've been cheating: comment out the conditional statement and adjust the > indents. But, how do I make my program run with if __name__ == 'main': > main() at the end? I thought I understood the idea to run a module called > directly but not a

[Tutor] conditional execution

2014-04-01 Thread Patti Scott
I've been cheating:  comment out the conditional statement and adjust the indents. But, how do I make my program run with if __name__ == 'main': main() at the end?  I thought I understood the idea to run a module called directly but not a module imported.  My program isn't running, though. Belo

[Tutor] Vending machine problem.

2014-04-01 Thread bob gailer
On 4/1/2014 3:26 AM, Sebastien Gomez wrote: The vending machine must have 5 prices with items it should accept 10p, 20p 50p and £1 coins it should allow the user to purchase a item and give him a choice of purchasing something else. it should display the remaining credit once the item is purcha

[Tutor] Vending machine problem.

2014-04-01 Thread bob gailer
I'm posting this to include you in this conversation. Recently I got the following Request: can you write me a code in python please or if you have one already my response: print('hello world') what more can I do for you? (next two lines are best guesses as I can't find the relevant emails.

Re: [Tutor] unittests

2014-04-01 Thread Steven D'Aprano
On Tue, Apr 01, 2014 at 12:30:46PM +0100, Sydney Shall wrote: > Another debutant! > I am having trouble learning to use unittests. > My question is; > In the example below, did you write the class > "SquareRootTests(unittest.TestCase):" ? Yes, that unit test was written by Danny (I assume --

[Tutor] unittests

2014-04-01 Thread Sydney Shall
Another debutant! I am having trouble learning to use unittests. My question is; In the example below, did you write the class "SquareRootTests(unittest.TestCase):" ? Or do I find a set of them in the library? And what is the significance of the name chosen "self.assertAlmostEqual(squ

Re: [Tutor] while loop

2014-04-01 Thread Alan Gauld
On 01/04/14 00:22, Scott Dunning wrote: def print_n(s,n): i = 0 while i < n: print s, i += 1 print_n('a',3) Also, with this exercise it’s using a doctest so I don’t actually call the function I have no idea what you mean buy this? There is no doctest above and yo

Re: [Tutor] exercise (while loop)

2014-04-01 Thread Alan Gauld
On 01/04/14 02:07, Scott W Dunning wrote: I’m working on a few exercises and I’m a little stuck on this one. This is what the book has but it just gives me an endless loop. def square_root(a, eps=1e-6): while True: print x y = (x + a/x) / 2

Re: [Tutor] while loop

2014-04-01 Thread Dave Angel
Scott Dunning Wrote in message: > > On Mar 31, 2014, at 5:15 AM, Dave Angel wrote: >> >> Do you know how to define and initialize a second local variable? >> Create one called i, with a value zero. >> >> You test expression will not have a literal, but compare the two >> locals. And the st

Re: [Tutor] exercise (while loop)

2014-04-01 Thread Dave Angel
Scott W Dunning Wrote in message: > I’m working on a few exercises and I’m a little stuck on this one. > > This is what the book has but it just gives me an endless loop. > > def square_root(a, eps=1e-6): > while True: > print x > y = (x + a/x) / 2 >

Re: [Tutor] exercise (while loop)

2014-04-01 Thread Mark Lawrence
On 01/04/2014 02:47, Danny Yoo wrote: On Mar 31, 2014 6:22 PM, "Scott W Dunning" mailto:scott@cox.net>> wrote: > > I’m working on a few exercises and I’m a little stuck on this one. > > This is what the book has but it just gives me an endless loop. > > def square_root(a, eps=1e-6): >

Re: [Tutor] while loop

2014-04-01 Thread Scott Dunning
On Mar 31, 2014, at 5:15 AM, Dave Angel wrote: > > Do you know how to define and initialize a second local variable? > Create one called i, with a value zero. > > You test expression will not have a literal, but compare the two > locals. And the statement that increments will change i, not