← 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.
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 * lionAfter running the above block of code, what is the value of
cow?
Answer: 33.0
The average score on this problem was 60%.
Consider the following four assignment statements.
bass = "5"
tuna = 2
sword = ["4.0", 5, 12.5, -10, "2023"]
gold = [4, "6", "CSE", "doc"]What is the value of the expression bass * tuna?
Answer: "55"
The average score on this problem was 48%.
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])
The average score on this problem was 51%.
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]))
The average score on this problem was 92%.
Consider the following assignment statement.
puffin = np.array([5, 9, 13, 17, 21])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.
The average score on this problem was 90%.
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: 2y: anything in (8,
10]z: 5
The average score on this problem was 74%.
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.
What type is students.get("Overall")? If this expression
errors, select “this errors."
float
string
array
Series
this errors
Answer: Series
The average score on this problem was 73%.
What type is students.get("PID")? If this expression
errors, select “this errors."
float
string
array
Series
this errors
Answer: this errors
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.
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
The average score on this problem was 69%.
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
The average score on this problem was 82%.