Fall 2023 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 2023 offering of DSC 10.


Problem 1

After a trip to the zoo, Anthony wrote the following block of code.

zebra = 5
lion = 4
cow = 1
zebra = zebra * 2
lion = abs(cow - lion)
zebra = zebra + lion ** 2
cow = (zebra + lion) / 2 * lion

After running the above block of code, what is the value of cow?

Answer: 33.0


Difficulty: ⭐️⭐️⭐️

The average score on this problem was 60%.


Problem 2

Consider the following four assignment statements.

bass = "5"
tuna = 2
sword = ["4.0", 5, 12.5, -10, "2023"]
gold = [4, "6", "CSE", "doc"]


Problem 2.1

What is the value of the expression bass * tuna?

Answer: "55"


Difficulty: ⭐️⭐️⭐️⭐️

The average score on this problem was 48%.


Problem 2.2

Which of the following expressions results in an error?

Answer: int(sword[0])


Difficulty: ⭐️⭐️⭐️

The average score on this problem was 51%.


Problem 2.3

Which of the following expressions evaluates to "DSC10"?

Answer: gold[3].replace("o", "s").upper() + str(gold[0] + int(gold[1]))


Difficulty: ⭐️

The average score on this problem was 92%.



Problem 3

Consider the following assignment statement.

puffin = np.array([5, 9, 13, 17, 21])


Problem 3.1

Provide arguments to call np.arange with so that the array penguin is identical to the array puffin.

penguin = np.arange(____)

Answer: We need to provide np.arange with three arguments: 5, anything in (21, 25], 4. For instance, something line penguin = np.arange(5, 25, 4) would work.


Difficulty: ⭐️

The average score on this problem was 90%.


Problem 3.2

Fill in the blanks so that the array parrot is also identical to the array puffin.
Hint: Start by choosing y so that parrot has length 5.

parrot = __(x)__ * np.arange(0, __(y)__, 2) + __(z)__

Answer:

  • x: 2
  • y: anything in (8, 10]
  • z: 5

Difficulty: ⭐️⭐️⭐️

The average score on this problem was 74%.



Problem 4

Suppose students is a DataFrame of all students who took DSC 10 last quarter. students has one row per student, where:


Problem 4.1

What type is students.get("Overall")? If this expression errors, select “this errors."

Answer: Series


Difficulty: ⭐️⭐️⭐️

The average score on this problem was 73%.


Problem 4.2

What type is students.get("PID")? If this expression errors, select “this errors."

Answer: this errors


Difficulty: ⭐️⭐️⭐️

The average score on this problem was 67%.


Vanessa is one student who took DSC 10 last quarter. Her PID is A12345678, she earned the sixth-highest overall percentage grade in the class, and her favorite animal is the giraffe.


Problem 4.3

Supposing that students is already sorted by "Overall" in descending order, fill in the blanks so that animal_one and animal_two both evaluate to "giraffe".

animal_one = students.get(__(x)__).loc[__(y)__]
animal_two = students.get(__(x)__).iloc[__(z)__]

Answer:

  • x: "Animal"
  • y: "A12345678"
  • z: 5

Difficulty: ⭐️⭐️⭐️

The average score on this problem was 69%.


Problem 4.4

If students wasn’t already sorted by "Overall" in descending order, which of your answers would need to change?

Answer: z only


Difficulty: ⭐️⭐️

The average score on this problem was 82%.



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