Given the following function, `odds`, which converts a\n`list` of `strings` into a `list` of only **odd\nintegers**:\n\n

\ndef odds(strings: list[str]) -> list[int]:\n numbers = []\n for string in strings:\n number = int(string)\n if number % 2:\n numbers.append(number)\n return numbers\n\n\n

Write a new function `odds_lc` that accomplishes the same task\nusing a **list comprehension**:

\ndef odds_lc(strings: list[str]) -> list[int]:\n return [____ for string in ____ if ____]\n\n" }, "q2": { "type": "blank", "question": "\n

Given the following function, `odds`, above, write a new function\n`odds_gr` that accomplishes the same task as a **generator**\nfunction:

\ndef odds_gr(strings: list[str]) -> ____[int]: # 1.\n for string in ____: # 2.\n number = ____ # 3.\n if ____: # 4.\n ____ number # 5.\n\n" }, "q3": { "type": "multiple", "question": "\n

Which of the following statements regarding the different `odds`\nfunctions are true (select all that apply)?

Which of the following statements regarding **binary heaps** are true\n(select all that apply)?

Which of the following **binary trees** are **binary heaps**\n(select all that apply)?

\n \n

\n",
"responses": {
"a": "A",
"b": "B",
"c": "C"
}
},
"q6": {
"type": "multiple",
"question": "\nSuppose we use the following **binary heap** to implement a\n**priority queue** and then perform a `pop()` operation to remove\nthe **largest** value. Which of the following statements are true\n(select all that apply)?

\n \n

\n",
"responses": {
"root_5": "After the Suppose we use the following **binary heap** to implement a\n**priority queue** and then perform a `push(6)` to add a new\nvalue. Which of the following statements are true (select all that\napply)?

\n \n

\n",
"responses": {
"root_7": "After the Using Python's `heapq` library, complete the following implementation of `heap_sort`:

\nimport heapq\n\ndef heap_sort(sequence):\n heap = ____\n for item in ____:\n ____(heap, item)\n return [____(heap) for _ in range(len(heap))]\n\n" } }