Free Practice Quiz Question List

2 Programming Foundations for Data Analysis Online Quiz Questions

Use this free practice quiz with 20 questions to review 2 Programming Foundations for Data Analysis, test your knowledge, and prepare for your next test or exam.

20 questions
01
True or false
1 point

In Python, are count and Count two different variable names?

  1. A

    True

  2. B

    False

02
Written response
1 point

Which Python keyword begins a function definition?

03
Fill in the blank
1 point

A loop repeats as long as its condition remains true.

04
Choose one
1 point

What value is assigned to status when this code runs?

reading = 100

if reading < 0:
    status = "check: negative reading"
elif reading > 100:
    status = "check: unusually high reading"
else:
    status = "within expected range"
  1. A

    check: negative reading

  2. B

    within expected range

  3. C

    check: unusually high reading

05
True or false
1 point

A data-analysis program should automatically treat every unusual reading as erroneous, without considering context.

  1. A

    True

  2. B

    False

06
Written response
1 point

A list contains the readings [4, -2, 8]. A program retains readings greater than or equal to zero and calculates the mean of the retained values. What is that mean?

07
Choose one
1 point

Given the code below, what value does first_reading contain after the assignment?

readings = [12.4, 15.0, 13.6]
first_reading = readings[0]
readings.append(14.2)
  1. A

    15.0

  2. B

    13.6

  3. C

    12.4

  4. D

    14.2

08
Choose one
1 point

What does this expression return if the dictionary has no region key?

station = {"name": "North"}
station.get("region", "unknown")
  1. A

    It raises a KeyError because the key is absent.

  2. B

    It returns unknown.

  3. C

    It adds the key region with the value unknown to the dictionary.

09
Choose all
1 point

Select all statements that accurately describe Python collections.

  1. A

    A list is an ordered, changeable sequence.

  2. B

    A tuple is an ordered, unchangeable sequence.

  3. C

    A dictionary associates keys with values.

  4. D

    A set holds distinct values.

  5. E

    A set is an ordered sequence that permits repeated values.

10
Choose all
1 point

Select all statements that correctly describe Python loops or safe practices when processing collections.

  1. A

    A for loop can process items in a collection in turn.

  2. B

    range() can generate a sequence of integers.

  3. C

    A while loop repeats as long as its condition remains true.

  4. D

    A loop variable can take the next item in the collection on each pass.

  5. E

    It is generally clearer and safer to change a collection while iterating over that same collection.

11
Fill in the blank
1 point

In this function, what value is returned when values is an empty list?

def mean(values):
    if len(values) == 0:
        return 

    return sum(values) / len(values)
12
Open ended
1 point

Suppose an analysis processes readings that may be negative. Explain how a loop, a conditional, a separate list, and a mean-calculating function can work together to produce the mean of nonnegative readings. Why should excluded readings be preserved or recorded?

13
Choose one
1 point

What is the type of the value returned by float("12.4")?

  1. A

    str

  2. B

    float

  3. C

    int

  4. D

    bool

14
True or false
1 point

A program finds a reading above 100. Based on the guidance for interpreting unusual values, should it automatically conclude that the reading is wrong?

  1. A

    True

  2. B

    False

15
Choose one
1 point

The dictionary station has no "region" key. What does station.get("region", "unknown") return?

  1. A

    station["region"] returns "unknown" if the key is missing.

  2. B

    station.get("region", "unknown") returns "unknown" if the key is missing.

  3. C

    station.get("region", "unknown") adds the key with value "unknown" to the dictionary.

  4. D

    station.get("region", "unknown") raises a KeyError if the key is missing.

16
Choose one
1 point

In Python, what index accesses the third item in a list?

  1. A

    1

  2. B

    2

  3. C

    3

  4. D

    4

17
Choose one
1 point

You need to store distinct values and do not need duplicates. Which Python collection best fits this purpose?

  1. A

    A list

  2. B

    A tuple

  3. C

    A set

  4. D

    A dictionary

18
Choose one
1 point

Given the Python statements below, what is the value of total after both statements run?

total = 3
total = total + 1
  1. A

    It checks whether total and total + 1 are equal.

  2. B

    It updates total from 3 to 4.

  3. C

    It raises a NameError because total has not been defined.

  4. D

    It changes total to the text value "4".

19
Written response
1 point

Using the mean function below, what numerical value is returned by mean([2, 4, 6])?

def mean(values):
    if len(values) == 0:
        return None
    return sum(values) / len(values)
20
Written response
1 point

Given is_ready = False and status = "False", what is the Python type of the value assigned to is_ready?