On Sat, Dec 01, 2012 at 09:19:57PM -0500, eryksun wrote:
> On Sat, Dec 1, 2012 at 11:31 AM, Dave Angel wrote:
> >
> > revdiag = [M[i][len(M)-1-i] for i in range(len(M)) ]
>
> You might sometimes see this using the bitwise invert operator ~ (i.e.
> __invert__, operator.invert):
>
> >>> M = [
On 12/01/2012 11:39 PM, Sujit Baniya wrote:
> *Write a function named countRepresentations that returns the
> number*>* of ways that an amount of money in rupees can be represented
> as rupee*>* notes. For this problem we only use rupee notes in
> denominations of*>* 1, 2, 5, 10 and 20 rupee notes
*Write a function named countRepresentations that returns the
number*>* of ways that an amount of money in rupees can be represented
as rupee*>* notes. For this problem we only use rupee notes in
denominations of*>* 1, 2, 5, 10 and 20 rupee notes.*>**>* The
signature of the function is:*>*def
On 12/01/2012 09:55 PM, eryksun wrote:
> On Sat, Dec 1, 2012 at 9:35 PM, Dave Angel wrote:
>>
>> [M[i][~i] for i,dummy in enumerate(M) ]
>
> Since enumerate() iterates the rows, you could skip the first index:
>
> >>> [row[~i] for i,row in enumerate(M)]
> [3, 5, 7]
>
>
Great job. And
On Sat, Dec 1, 2012 at 9:35 PM, Dave Angel wrote:
>
> [M[i][~i] for i,dummy in enumerate(M) ]
Since enumerate() iterates the rows, you could skip the first index:
>>> [row[~i] for i,row in enumerate(M)]
[3, 5, 7]
___
Tutor maillist - Tutor@py
On 12/01/2012 09:19 PM, eryksun wrote:
> On Sat, Dec 1, 2012 at 11:31 AM, Dave Angel wrote:
>>
>> revdiag = [M[i][len(M)-1-i] for i in range(len(M)) ]
>
> You might sometimes see this using the bitwise invert operator ~ (i.e.
> __invert__, operator.invert):
>
> >>> M = [[1, 2, 3], [4, 5, 6]
On Sat, Dec 1, 2012 at 11:31 AM, Dave Angel wrote:
>
> revdiag = [M[i][len(M)-1-i] for i in range(len(M)) ]
You might sometimes see this using the bitwise invert operator ~ (i.e.
__invert__, operator.invert):
>>> M = [[1, 2, 3], [4, 5, 6], [7, 8, 9]]
>>> [M[i][~i] for i in xrange(len(M
On 1 December 2012 20:12, Dave Angel wrote:
> On 12/01/2012 11:28 AM, Brian van den Broek wrote:
>> On 1 December 2012 10:40, richard kappler wrote:
>>> I'm working through Mark Lutz's "Python," reviewing the section on lists. I
>>> understand the list comprehension so far, but ran into a snag wi
On 12/01/2012 11:28 AM, Brian van den Broek wrote:
> On 1 December 2012 10:40, richard kappler wrote:
>> I'm working through Mark Lutz's "Python," reviewing the section on lists. I
>> understand the list comprehension so far, but ran into a snag with the
>> matrix. I've created the matrix M as fol
Ashfaq,
On Sat, Dec 1, 2012 at 10:46 AM, Ashfaq wrote:
> Run your code 10,000 times. :)
>
>
> ** **
>>
>> import math
>>
>> import random
>>
>> random.seed()
>>
>>
> there is no need to call seed() with no parameters. From the docs:
""" If *x* is omitted or None, current system tim
Run your code 10,000 times. :)
** **
>
> import math
>
> import random
>
> random.seed()
>
>
points = []
for i in range(0, 1):
x=random.uniform(0,1)
y=random.uniform(0,1)
points.append ( (x, y) )
I hope it helps.
--
Sincerely,
Ashfaq
On 1 December 2012 10:40, richard kappler wrote:
> I'm working through Mark Lutz's "Python," reviewing the section on lists. I
> understand the list comprehension so far, but ran into a snag with the
> matrix. I've created the matrix M as follows:
>
> M = [[1, 2, 3[, [4, 5, 6], [7, 8, 9]]
>
> then
On 12/01/2012 10:40 AM, richard kappler wrote:
> I'm working through Mark Lutz's "Python," reviewing the section on lists. I
> understand the list comprehension so far, but ran into a snag with the
> matrix. I've created the matrix M as follows:
>
> M = [[1, 2, 3[, [4, 5, 6], [7, 8, 9]]
There's an
On Sat, Dec 1, 2012 at 9:40 AM, richard kappler wrote:
> I'm working through Mark Lutz's "Python," reviewing the section on lists. I
> understand the list comprehension so far, but ran into a snag with the
> matrix. I've created the matrix M as follows:
>
> M = [[1, 2, 3[, [4, 5, 6], [7, 8, 9]]
>
>>> revdiag = [M[i][i] for i in [2, 1, 0]]
>>> revdiag
[9, 5, 1]
The reverse diag entries (that you are seeking to get) are not correct.
They should be M[0][2], M[1][1], M[2][0].
So the code could be --
revdiag = []
for i in [0, 1, 2]:
j = 2 - i
revdiag.append( M[i][j] )
I hope it helps.
I'm working through Mark Lutz's "Python," reviewing the section on lists. I
understand the list comprehension so far, but ran into a snag with the
matrix. I've created the matrix M as follows:
M = [[1, 2, 3[, [4, 5, 6], [7, 8, 9]]
then ran through the various comprehension examples, including:
d
On Sat, Dec 1, 2012 at 2:30 AM, Steven D'Aprano wrote:
>
>> The length and order of the optional byte order mark (BOM)
>> distinguishes UTF-16LE, UTF-16BE, UTF-32LE, and UTF-32BE.
>
> That's not quite right. The UTF-16BE and UTF-16LE character sets do
> not take BOMs, because the encoding already
17 matches
Mail list logo