BADM 211 Midterm Review (practice problems) Questions with Correct
Answers
Question 1:
What is the output of the following lines of code: word = "BADM" word = 211
print(word)
Answer:
211
Question 2:
What will the result of the following code? 2 * "3.0"
Answer:
"3.03.0"
Question 3:
Which of the following pandas methods will report summary statistics of numeric columns?
head()
tail()
info() describe()
Answer:
D. describe()
Question 4:
Suppose we have a data frame df, which includes a column animal. I would like to count the
number of times each animal appears in the column, e.g. Elephant: 8, Zebra: 7, etc. Which of
the following commands can I use to do that?
df["animal"].value_counts() df["animal"].value_counts(normalize=True)
df.value_counts().animal() value_counts(df["animal"])
Answer:
A. df["animal"].value_counts()
Question 5:
Which option will help us select elements "a" and "b" in the list L = ["a", "b", "c"]? (Select all
that apply.) L[0:2]
L[1:2] L[-3:-2]
Answers
Question 1:
What is the output of the following lines of code: word = "BADM" word = 211
print(word)
Answer:
211
Question 2:
What will the result of the following code? 2 * "3.0"
Answer:
"3.03.0"
Question 3:
Which of the following pandas methods will report summary statistics of numeric columns?
head()
tail()
info() describe()
Answer:
D. describe()
Question 4:
Suppose we have a data frame df, which includes a column animal. I would like to count the
number of times each animal appears in the column, e.g. Elephant: 8, Zebra: 7, etc. Which of
the following commands can I use to do that?
df["animal"].value_counts() df["animal"].value_counts(normalize=True)
df.value_counts().animal() value_counts(df["animal"])
Answer:
A. df["animal"].value_counts()
Question 5:
Which option will help us select elements "a" and "b" in the list L = ["a", "b", "c"]? (Select all
that apply.) L[0:2]
L[1:2] L[-3:-2]