Free Practice Quiz Question List

1 Programming Foundations for Data Science Online Quiz Questions

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

20 questions
01
Choose one
1 point

Which Python collection is an ordered, changeable sequence that suits values you may add, remove, or update?

  1. A

    A tuple, because it is ordered and changeable.

  2. B

    A list, because it is ordered and changeable.

  3. C

    A set, because it is ordered and changeable.

  4. D

    A dictionary, because it is an ordered sequence accessed by position.

02
True or false
1 point

True or false: In Python, the value "12" has type int because it contains digits.

  1. A

    True

  2. B

    False

03
Written response
1 point

What is the built-in type name of the Python value None?

04
Fill in the blank
1 point

A dictionary value is retrieved by looking up a rather than by position.

05
Choose one
1 point

A data-cleaning task needs to remove duplicate site names and check whether a site is present. Which collection is the best fit?

  1. A

    A tuple

  2. B

    A list

  3. C

    A set

  4. D

    A dictionary

06
Choose all
1 point

Select all statements that correctly describe lists and tuples in Python.

  1. A

    A list is ordered and changeable.

  2. B

    A tuple is changeable after creation.

  3. C

    A tuple is ordered and not changeable after creation.

  4. D

    A list has no positional indexing.

07
True or false
1 point

True or false: In a Python condition, both zero and an empty collection are treated as false.

  1. A

    True

  2. B

    False

08
Written response
1 point

Given location = (40.7, -74.0), what numeric value does location[1] produce?

09
Choose one
1 point

What value is assigned to label by this code when score is 75?

if score is None:
    label = "missing"
elif score >= 80:
    label = "high"
else:
    label = "other"
  1. A

    "missing"

  2. B

    "high"

  3. C

    "other"

  4. D

    The code raises an error because 75 is not None.

10
Fill in the blank
1 point

A for loop visits each in an iterable.

11
Choose all
1 point

Select all statements that correctly describe Python functions.

  1. A

    A parameter can provide an input to a function.

  2. B

    A function must have a return statement to run.

  3. C

    A return statement can send a result back to the caller.

  4. D

    A function that reaches its end without return returns 0.

12
Choose one
1 point

Inside a loop, which keyword skips the rest of the current iteration and proceeds to the next one?

  1. A

    break

  2. B

    continue

  3. C

    return

  4. D

    elif

13
True or false
1 point

True or false: To avoid an endless while loop, its condition should be able to become false eventually.

  1. A

    True

  2. B

    False

14
Open ended
1 point

Explain how mean_score handles missing scores and avoids division by zero when no scores are available.

15
Written response
1 point

How many times does the loop body run in for i in range(4):?

16
Written response
1 point

Given location = (40.7, -74.0), what value does location[0] return? Enter the value as a number.

17
Choose one
1 point

What is true after these statements run?

reading = 18
reading = "unavailable"
  1. A

    Python raises an error because a variable must keep its original type.

  2. B

    The name reading refers to the string value after the second assignment.

  3. C

    The second assignment changes the string into an integer.

  4. D

    The name reading refers to both values at the same time.

18
Choose one
1 point

A program receives an external text field that may contain "27x". What should its author keep in mind before using int(field)?

  1. A

    The conversion always succeeds because the input is a string.

  2. B

    The conversion silently changes invalid characters to zero.

  3. C

    The conversion may fail, so the external value should be checked before relying on it.

  4. D

    The conversion always returns None when the text is invalid.

19
Choose one
1 point

What happens when break runs inside the inner loop in this nested-loop structure?

for group in groups:
    for item in group:
        if should_stop(item):
            break
  1. A

    The inner loop stops, and the outer loop can continue.

  2. B

    Both loops stop immediately.

  3. C

    Only the outer loop stops; the inner loop continues.

  4. D

    The program skips the current iteration of both loops and resumes both.

20
Choose one
1 point

Given score = 86 and attempts = 3, what is the result of this condition?

score >= 80 and attempts < 3
  1. A

    The condition is true because score is at least 80.

  2. B

    The condition is true because attempts is less than 3.

  3. C

    The condition is true because and means either comparison may be true.

  4. D

    The condition is false because one of the two comparisons is false.