On Fri, Aug 20, 2010 at 2:48 PM, Roelof Wobben <rwob...@hotmail.com> wrote:
> Oke, > > I don''t understand it complety. > > return not arg%2 > > Why use not here ? > > I think that arg%2 is True not makes it false. > What happens when you replace arg with a value? % is modulo division, so it just returns the remainder. 2 % 2 = ? 4 % 2 = ? 7 % 2 = ? 11 % 2 = ? What is the truth value of 0 and 1? print 'True' if 0 else 'False' print 'True' if 1 else 'False' So what is the outcome of the following? result = 2 % 2 print result, not result if not result: print 'Even' if result: print 'odd' > > Another question. > > How can I round outcome of a calculation. > > round ( ( t-32)/1.8) does not work because I get a message that there are > two arguments. > > Outcome = (t-32)/1.8 > outcome2 = round (outcome) does not work because the argument must be a > string or a number > What is the type of t? In [39]: t = 3 In [40]: round((t-32)/1.8) Out[40]: -16.0 In [41]: t = 3.0 In [42]: round((t-32)/1.8) Out[42]: -16.0 Works fine for me. HTH, Wayne
_______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor