Which python package can be used for writing unit tests?
Blog
Consider the following recursive function: def r(xs: list[in…
Consider the following recursive function: def r(xs: list[int]) -> list[int]: match xs: case []: return [] case [x]: return [x] case [first, second, *rest]: return [first] + r(rest) + [second] What list will r([1, 2, 3, 4]) return?
Consider the following recursive function: def p(xs: list[in…
Consider the following recursive function: def p(xs: list[int]) -> list[int]: match xs: case []: return [] case [x]: return [x] case [first, second, *rest]: return p(rest) + [first, second] What list will p([1, 2, 3, 4, 5]) return?
Consider the following recursive function: def bad_len(xs: l…
Consider the following recursive function: def bad_len(xs: list[int]) -> int: match xs: case []: return 0 case nums: # here, nums: list[int] return nums[0] + bad_len(nums) What is the best fix?
Which sorting algorithm sorts selects the next item, finds a…
Which sorting algorithm sorts selects the next item, finds and inserts it into the correct position in the sorted sequence of the list?
The function at_least returns True if at least two values in…
The function at_least returns True if at least two values in a list of booleans are True. Provide the Big‑O running time for the following function. def at_least( arr: list[bool] ) -> None: count = 0 for i in range(0, len(arr)): if arr[i] == True: count += 1 return count >= 2
Consider the following variation of the selection sort algor…
Consider the following variation of the selection sort algorithm: def sort(values: list[int]) -> None : for i in range(len(values)) : maxPos = i for j in range(i + 1, len(values)) : if values[j] > values[maxPos] : maxPos = j temp = values[maxPos] values[maxPos] = values[i] values[i] = values[maxPos] If this algorithm takes 5 seconds to sort 15,000 elements, how long would you expect it to take to sort 30,000 elements?
Which of the following occupancy factors would accurately de…
Which of the following occupancy factors would accurately describe total occupancy (administrative or clerical offices, adjacent x-ray rooms, nurses stations, etc)?
During routine radiographic procedures, when a protective ap…
During routine radiographic procedures, when a protective apron is not being used, occupational personnel should place the primary dosimeter at the front of the body at the collar level to approximate the location of maximal radiation dose to which of the following body parts?
What is a shield law?
What is a shield law?