Written by students who passed Immediately available after payment Read online or as PDF Wrong document? Swap it for free 4.6 TrustPilot
logo-home
Exam (elaborations)

CS 7646 MIDTERM EXAM 1 QUESTIONS AND ANSWERS

Rating
-
Sold
-
Pages
11
Grade
A+
Uploaded on
14-03-2026
Written in
2025/2026

CS 7646 MIDTERM EXAM 1 QUESTIONS AND ANSWERS 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 ANSWERC, 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

Show more Read less
Institution
CS 7646
Course
CS 7646

Content preview

CS 7646 MIDTERM EXAM 1 QUESTIONS AND ANSWERS
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

Written for

Institution
CS 7646
Course
CS 7646

Document information

Uploaded on
March 14, 2026
Number of pages
11
Written in
2025/2026
Type
Exam (elaborations)
Contains
Questions & answers

Subjects

$13.99
Get access to the full document:

Wrong document? Swap it for free Within 14 days of purchase and before downloading, you can choose a different document. You can simply spend the amount again.
Written by students who passed
Immediately available after payment
Read online or as PDF

Get to know the seller

Seller avatar
Reputation scores are based on the amount of documents a seller has sold for a fee and the reviews they have received for those documents. There are three levels: Bronze, Silver and Gold. The better the reputation, the more your can rely on the quality of the sellers work.
STANGRADES Stanford University
Follow You need to be logged in order to follow users or courses
Sold
88
Member since
1 year
Number of followers
1
Documents
12011
Last sold
1 month ago
STAN-GRADES

EXCELLENCY IN ACADEMIC MATERIALS

3.4

14 reviews

5
6
4
1
3
3
2
1
1
3

Recently viewed by you

Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their tests and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can instantly pick a different document that better fits what you're looking for.

Pay as you like, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Working on your references?

Create accurate citations in APA, MLA and Harvard with our free citation generator.

Working on your references?

Frequently asked questions