Checkpoint
The interview and this lab
Twelve questions across the three lessons, on inputs you have not seen. Trace every program by hand before you answer, the way you would in a round with no Run button. You pass at 80%.
- Question 1 of 12.
A candidate tested this once:
largest([7, 3, 5])returned 7, which is right.def largest(nums): best = nums[0] for i in range(len(nums) - 1): if nums[i] > best: best = nums[i] return bestWhich one input exposes the bug?
- Question 2 of 12.
You have five years of data engineering behind you, and a recruiter mentions a mid-level loop. Which statement fits the research?
- Question 3 of 12.
Your set version of
has_duplicateworks. The interviewer asks: "Now the list arrives sorted, smallest first, like[1, 3, 3, 8]. Can you do it without the set?" Which answer names the follow-up type and answers it well? - Question 4 of 12.
This function is meant to return the smallest number in a list. Type exactly what the program prints, one value per line.
def smallest(nums): low = 0 for x in nums: if x < low: low = x return low print(smallest([-3, 5, -6])) print(smallest([4, 2, 9])) - Question 5 of 12.
This loop finds the coldest reading of a day:
temps = [12, 9, 15, 7, 10] coldest = temps[0] for t in temps: if t < coldest: coldest = tWhich sentence is the promise it keeps?
- Question 6 of 12.
The pair version runs on
[6, 2, 8, 2]. How many times does the lineif nums[i] == nums[j]:run before the function returns True? Type a whole number.def has_duplicate(nums): for i in range(len(nums)): for j in range(i + 1, len(nums)): if nums[i] == nums[j]: return True return FalsecomparisonsType a number: 12, -1, 0.5 and 3/4 all work.
- Question 7 of 12.
Someone swapped two lines of the set version. Type exactly what the program prints, one value per line.
def has_duplicate(nums): seen = set() for x in nums: seen.add(x) if x in seen: return True return False print(has_duplicate([1, 2, 3])) print(has_duplicate([4, 4])) print(has_duplicate([])) - Question 8 of 12.
Run the tests before you submit. This question counts as correct if your latest run passes every check.
Code itRecord days Daily order counts arrive as a list. A day sets a record when its count is strictly greater than every earlier day's count. The first day always sets one, since nothing came before it. Write
count_records(orders), which returns how many days set a record.For
[3, 5, 2, 8, 8, 9]the answer is 4: the 3, the 5, the first 8 and the 9. An empty list has no records.Write your code where the starter saysraise NotImplementedError, then press Run tests. Each check says what it expects. - Question 9 of 12.
One problem's history: clean solves on days 0 and 1, the solution opened on day 4, then clean solves on days 5 and 6. The lab's ladder uses gaps of 1, 3, 7, 14 and 30 days, counted from the latest solve. On what day is the next re-solve due? Type the day number.
dayType a number: 12, -1, 0.5 and 3/4 all work.
- Question 10 of 12.
The prompt said: count the days with at least
korders. You wroteif x > k:, traced an example where no day had exactlykorders, and submitted. A hidden test with a day of exactlykorders failed. Which type of miss is this? - Question 11 of 12.
Eight minutes into a new medium problem, you are stuck. You have read the prompt three times and written nothing. What does the struggle cap say to do?
- Question 12 of 12.
You have finished modules 3, 4 and 5 and solved each lesson's problems in a row. Your weekend block is free. Which session fits the research best?