← return to practice.dsc10.com
This quiz was administered in-person. Students were allowed a cheat
sheet. Students had 20 minutes to work on the
quiz.
This quiz covered Lectures 1-6 of the Winter 2025 offering
of DSC 10.
The DataFrame clubs
contains information about all the
studemt organizations at UCSD. For each club, we have its
"Name"
, "Category"
, number of
"Members"
, "Budget"
in dollars,
"Rating"
out of 5.0
, and whether it is
"Active"
represented by either True
or
False
. The first three rows of clubs are shown below.
Assume that all club names are unique.
The Cheese Club currently has 50 members. Each quarter, the number of people who will join the club is the value of the Python expression below.
3 * ((4 * 20 / 5 * 2 + 4) ** 0.5 - 2 ** 2)
How many members will the club have after 3 quarters?
56
68
74
82
None of these.
Answer: 68
The average score on this problem was 65%.
How many unique data types exist in the clubs
DataFrame?
2
3
4
5
6
None of these.
Answer: 4
The average score on this problem was 61%.
Suppose we run the following code.
= ["Cheese Club".upper(), str(int(4.6)), "Painting Club".title(), 3.7 - 1]
clubs_and_ratings = np.array(clubs_and_ratings) a
What do a[0]
, a[1]
, a[2]
, and
a[3]
evaluate to?
Answer:
a[0]
: "CHEESE CLUB"
a[1]
: "4"
a[2]
: "Painting Club"
a[3]
: "2.7"
The average score on this problem was 75%.
One of the clubs in the clubs
DataFrame is the
"Surf Club"
. Without querying, write an
expression that evaluates to the rating of this club.
Answer:
clubs.set_index("Name).get("Rating").loc["Surf Club"]
The average score on this problem was 62%.
Now, using a query, write an expression that evaluates to the rating
of the "Surf Club"
.
Answer:
clubs[clubs.get("Name") == "Surf Club"].get("Rating").iloc[0]
The average score on this problem was 48%.
Fill in the blanks so the expression below evaluates to the name of
the category (e.g. "Social"
) with the largest number of
members, on average.
="Members", ascending=__(c)__).__(d)__) (clubs.groupby(__(a)__).__(b)__.sort_values(by
Answer:
(a)
: "Category"
(b)
: mean()
(c)
: False
(d)
: index[0]
The average score on this problem was 59%.
In each category, what is the largest budget for a club? Write one line of code that would produce an appropriate data visualization to answer this question.
Answer:
clubs.groupby("Category").max().plot(kind= "bar", y= "Budget")
The average score on this problem was 38%.
The Data Science Student Society has a $500
budget,
which they will use only to buy food for their 4 meetings this quarter.
Each time they have a meeting, they will use exactly half of their
remaining budget on food. For example, the first meeting’s food cost
will be $250
and the next meeting’s food cost will be
$125
. Use np.arange()
, together with
arithmetic operations, to assign food_costs
to an array
containing the food cost for each of the 4 meetings. Do
not use np.array()
.
food_costs =
Answer: 500 * 0.5 ** np.arange(1,5)
or
500/2 ** np.arange(1,5)
The average score on this problem was 11%.