Fall 2024 Quiz 1

← return to practice.dsc10.com


This quiz was administered in-person. It was closed-book and closed-note; students were not allowed to use the DSC 10 Reference Sheet. Students had 20 minutes to work on the quiz.

This quiz covered Lectures 1-4 of the Fall 2024 offering of DSC 10.


Problem 1

What does the following expression evaluate to? Write your answer exactly how the output would appear in Python.

5 * (4 ** 3 - 40) / (2 * 8) ** .5 + 10 / 3 + 2 * (5 / 6 - 1 / 2)

Answer: 34.0


Difficulty: ⭐️⭐️⭐️

The average score on this problem was 61%.


Problem 2

Select all the answer choices below that correspond to valid assignment statements.

Answer:

  • Option 2: 18
  • Option 4: "error????"

Difficulty: ⭐️⭐️

The average score on this problem was 78%.


Problem 3

Suppose that weights is an array containing the weights, in kilograms, of several leopard sharks living in La Jolla Cove. Several leopard sharks represented in weights weigh more than 10 kilograms.

Suppose that we have imported a module called sharkpy by running the code import sharkpy. The sharkpy module includes a function heavy that takes as input an array of shark weights and returns a smaller array containing only the weights that are above 10 kilograms.

Using the heavy function and an array method of your choice, write an expression that evaluates to the weight, in kilograms, of the lightest leopard shark in weights that weighs more than 10 kilograms.

Answer: sharkpy.heavy(weights).min()


Difficulty: ⭐️⭐️⭐️

The average score on this problem was 59%.


Problem 4

Suppose we run the following code.

creatures = "crab, eel, clam"
oceans = "Pacific, Atlantic"
creatures = creatures.title()
oceans = oceans.upper()
creatures = creatures.replace("clam", "lobster")

What does the expression creatures + ", " + oceans evaluate to? Write your answer exactly how the output would appear in Python.

Answer: "Crab, Eel, Clam, PACIFIC, ATLANTIC"


Difficulty: ⭐️⭐️⭐️

The average score on this problem was 66%.


Problem 5

Define narwhal and jellyfish as follows.

narwhal = np.arange(6, 12, 3)
jellyfish = np.arange(12, 6, -3)


Problem 5.1

True or False: narwhal.sum() and jellyfish.sum() evaluate to the same value.

Answer: False


Difficulty: ⭐️⭐️

The average score on this problem was 86%.


Problem 5.2

True or False: (narwhal+jellyfish)[0] and (narwhal+jellyfish)[1] evaluate to the same value.

Answer: True


Difficulty: ⭐️

The average score on this problem was 92%.



Problem 6

The DataFrame finding_nemo contains information about characters in the movie Finding Nemo. Each row represents a character, and the columns include:

There is one character in finding_nemo named "Bruce". Which of the following lines of code evaluates to Bruce’s species?

Answer: finding_nemo.set_index("Name").get("Species").loc["Bruce"]


Difficulty: ⭐️⭐️

The average score on this problem was 80%.


👋 Feedback: Find an error? Still confused? Have a suggestion? Let us know here.