Academic Year 2022 Actual

Python actual test – session 2

General note: The following code is executed as the first cell of the notebook in which all other problems’ codes are run.

import numpy as np from scipy.integrate 
import solve_ivp 
import scipy.stats as st from scipy 
import signal 
import matplotlib.pyplot as plt 

1. What is the output of this code?

A = np.array([ [1, 0],[0, -1] ])
b = np.array([-42, 42])

print(sum(np.dot(A, b)))
| A   | B   | C   | D | E  | F  | G  |
|-----|-----|-----|---|----|----|----|
| -84 | -42 | -21 | 0 | 21 | 45 | 84 |

2. What is the output of this code?

A = np.arange(9).reshape(3, -1) 
print((A - 3)[:, 1])

A. [-3 0 3] B. [0 1 2] C. [-3 -2 -1] D. [-2 1 4] E. [-1 2 5] F. [1 4 7] G. [3 4 5]

| A        | B       | C          | D        | E        | F       | G       |
|----------|---------|------------|----------|----------|---------|---------|
| [-3 0 3] | [0 1 2] | [-3 -2 -1] | [-2 1 4] | [-1 2 5] | [1 4 7] | [3 4 5] |

3. What is the output of this code?

A.

B.

C.

D.

E.

4. What is the output of this code?

5. What is the output of this code?

A.

B.

C.

D.

6. What is the output of this code?

A.

B.

C.

D.

E.

Last updated