Use list comprehension to generate the list of all perfect numbers less than 10,000, .
What is their sum ?
Assumptions and Details
Suppose you're working on code for a molecular dynamics visualization. You need to represent various matrices, like the 3d rotation matrix, using Python lists. We can do so by using lists of lists.
For example, the matrix
is represented by
1 |
|
and the matrix
would be
1 |
|
The fragments below are designed to perform operations on matrices. Your task is to match the function bodies with the correct function definitions.
A:
1 2 |
|
B:
1 2 3 |
|
C:
1 2 3 |
|
The function bodies are given by the following
1:
1 2 |
|
2:
1 |
|
3:
1 |
|
In scientific computing, it is a common task to take the transpose of a matrix. The transpose of a matrix , , is found by turning all the rows of a matrix into columns and vice versa. More formally the transpose of a matrix is found by reflecting over its main diagonal.
For example, the transpose of
is given by
Which of the following snippets of code would correctly transpose the matrix ?
A:
1 2 |
|
B:
1 2 |
|
C::
1 2 |
|
D::
1 2 |
|