On 2015-10-14 12:27, Peter Otten wrote:
Alex Kleider wrote:
On 2015-10-13 14:44, Alex Kleider wrote:
On 2015-10-13 12:11, Danny Yoo wrote:
##
def make_ask(f, l, p):
d = {'Enter your first name: ' : f,
'Enter your last name: ' : l,
'Your mobile p
On Wed, Oct 14, 2015 at 01:47:02PM -0700, ਨਿਹੰਗ ਪੰਜਾਬੀ wrote:
> 'if (n & 1)' below works but I don't understand why/how. Kindly help.
>
> ==
> >>> def fn(n):
> ... if (n & 1):
> ... print "n is odd"
> ... else:
> ... print "n is even"
& is the "bitwise AND"
On Wed, Oct 14, 2015 at 7:39 PM, Laura Creighton wrote:
> In a message of Wed, 14 Oct 2015 19:29:47 -0400, Joel Goldstick writes:
> >& is a bitwise operator, so any odd number and 1 will be one (true), and
> >any even number will be zero (false)
>
> You and Ben seem to have missed the problem in
In a message of Wed, 14 Oct 2015 19:29:47 -0400, Joel Goldstick writes:
>& is a bitwise operator, so any odd number and 1 will be one (true), and
>any even number will be zero (false)
You and Ben seem to have missed the problem in the answer.
I think that Ni needs to understand _how bitwise operat
To elaborate a little more this is comparing the 'one' bit. Any odd number
will have the 'one' bit set.
On Oct 14, 2015 6:30 PM, "Joel Goldstick" wrote:
> On Wed, Oct 14, 2015 at 4:47 PM, ਨਿਹੰਗ ਪੰਜਾਬੀ wrote:
>
> > 'if (n & 1)' below works but I don't understand why/how. Kindly help.
> >
> > =
On 14/10/15 21:47, ਨਿਹੰਗ ਪੰਜਾਬੀ wrote:
'if (n & 1)' below works but I don't understand why/how. Kindly help.
Do you understand what bitwise & does?
It takers the logical AND of each bit in the two operands.
So, keeping it simple with 2 digit numbers we get
0 = 00
1 = 01
2 = 10
3 = 11
Not
ਨਿਹੰਗ ਪੰਜਾਬੀ writes:
> 'if (n & 1)' below works but I don't understand why/how. Kindly
> help.
Can you kindly help us understand your confusion? You chose a subject
field that indicates why it works, so I don't know what your specific
confusion is.
--
\“Telling pious lies to trust
On Wed, Oct 14, 2015 at 4:47 PM, ਨਿਹੰਗ ਪੰਜਾਬੀ wrote:
> 'if (n & 1)' below works but I don't understand why/how. Kindly help.
>
> ==
> >>> def fn(n):
> ... if (n & 1):
> ... print "n is odd"
> ... else:
> ... print "n is even"
> ...
> >>> fn(5)
> n is odd
> >
'if (n & 1)' below works but I don't understand why/how. Kindly help.
==
>>> def fn(n):
... if (n & 1):
... print "n is odd"
... else:
... print "n is even"
...
>>> fn(5)
n is odd
>>> fn(4)
n is even
===
Thanks
Ni
___
Alex Kleider wrote:
> On 2015-10-13 14:44, Alex Kleider wrote:
>> On 2015-10-13 12:11, Danny Yoo wrote:
>>
>>
>>> ##
>>> def make_ask(f, l, p):
>>> d = {'Enter your first name: ' : f,
>>>'Enter your last name: ' : l,
>>>'Your mobile phone #: ' : p}
On 2015-10-14 11:29, Danny Yoo wrote:
##
def make_ask(f, l, p):
d = {'Enter your first name: ' : f,
'Enter your last name: ' : l,
'Your mobile phone #: ' : p}
return d.get
##
This is an example of a 'closure' is it not?
Y
>>> ##
>>> def make_ask(f, l, p):
>>> d = {'Enter your first name: ' : f,
>>>'Enter your last name: ' : l,
>>>'Your mobile phone #: ' : p}
>>> return d.get
>>> ##
>
>
> This is an example of a 'closure' is it not?
Yes, though
On 2015-10-13 14:44, Alex Kleider wrote:
On 2015-10-13 12:11, Danny Yoo wrote:
##
def make_ask(f, l, p):
d = {'Enter your first name: ' : f,
'Enter your last name: ' : l,
'Your mobile phone #: ' : p}
return d.get
##
This i
13 matches
Mail list logo