What is the output of the following Python session?
>>> def func(x = 2):...
b = 2...
return x * b...
>>> x = 3
>>> b = 3
>>> print func()
A)2
B)6
C)4
D)9 - CORRECT ANSWER✅✅C, because both variables x and b are defined outside the scope of func;
additionally, x is not passed as a parameter, so the default is used, resulting in 2x2=4
What is the output of the following Python session?
>>> a = 3
>>> b = a
>>> a = 2
>>> print b * a
A)4
B)6
C)3
D)2 - CORRECT ANSWER✅✅B, because a->3, b->3, a->2, thus 3*2=6
Consider the following Python session and its output. What should you replace XXXX with in order to get
the following output?
>>> a = np.random.uniform(size=(3,2))
>>> b = a/a[1,:]
, >>> print XXXX
1.0
A)b[0,1]
B)b[1,1]
C)a[0,1]
D)a[1,1] - CORRECT ANSWER✅✅B. a produces a random 2d array of size 3rx2c. a[1,:] refers to the 1th
row of a, all columns. b divides a by the 1th row of a, thus all values are 1 in the 1th row. b[1,1] is the
value in the 1th row, 1th column, so it would be 1.
4.Consider the following data:
COL_1 COL_2 COL_3
100.00 0.00 0.00
101.00 0.01 0.01
102.00 0.02 0.01
100.00 0.00 -0.02
102.00 0.02 0.02
What might the data in each of the columns represent (from left to right)?
A) Cumulative return, portfolio value, daily return
B) Daily return, portfolio value, cumulative return
C) Cumulative return, daily return, portfolio value
D) Portfolio value, cumulative return, daily return - CORRECT ANSWER✅✅D is the best choice, because
COL_1 looks like stock prices, COL_2 looks like some sort of sum of COL_3, which would correspond to
the daily return
Which code snippet below would correctly calculate the Sharpe ratio for time series daily_rets that
represents 60 days of daily returns? The risk free rate is represented by rfr