# Fall 2023 Quiz 1

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?

• int(sword[0])

• float(sword[1])

• int(sword[2])

• int(sword[3])

• float(sword[4])

Answer: int(sword[0])

##### Difficulty: ⭐️⭐️⭐️

The average score on this problem was 51%.

### Problem 2.3

Which of the following expressions evaluates to "DSC10"?

• gold[3].replace("o", "s").title() + str(gold[0] + gold[1])

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

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

• gold[3].replace("o", "s").title() + str(gold[0] + int(gold[1]))

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)__

• 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:

• The index contains students’ PIDs as strings starting with "A".

• The "Overall" column contains students’ overall percentage grades as floats.

• The "Animal" column contains students’ favorite animals as strings.

### Problem 4.1

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

• float

• string

• array

• Series

• this errors

##### 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."

• float

• string

• array

• Series

• 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)__]

• 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?

• Neither y nor z would need to change

• Both y and z would need to change

• y only

• z only

Answer: z only

##### Difficulty: ⭐️⭐️

The average score on this problem was 82%.