Complete the code to create an array with 5 elements initialized to zero.
array = [[1]] * 5 print(array)
The array is initialized with zeros using 0. This creates a list of five zeros.
Complete the code to define a Node class for a linked list with a value and a next pointer.
class Node: def __init__(self, value): self.value = value self.[1] = None
The next attribute points to the next node in the linked list.
Fix the error in the code that appends a new node to the end of a linked list.
def append_node(head, value): new_node = Node(value) current = head while current.[1] is not None: current = current.next current.next = new_node return head
The loop should check current.next to find the last node.
Fill both blanks to create a dictionary comprehension that maps array indices to their values if the value is even.
{i: arr[i] for i in range(len(arr)) if arr[i] [1] 2 == 0 and i [2] 5}The modulo operator % checks if a number is even. The comparison < filters indices less than 5.
Fill all three blanks to create a linked list from a list of values and print the values.
head = Node([1]) current = head for val in values[1:]: current.[2] = Node(val) current = current.[3] # Print linked list values while head is not None: print(head.value, end=' -> ') head = head.next print('None')
The first node is created with values[0]. The next attribute links nodes and moves the current pointer forward.