Complete the code to connect two blocks with a signal line.
add_block('simulink/Sources/Sine Wave', 'model/SineWave'); add_block('simulink/Sinks/Scope', 'model/Scope'); add_line('model', 'SineWave/1', [1], 'autorouting', 'on');
The signal line connects the output port 1 of the Sine Wave block to the input port 1 of the Scope block.
Complete the code to connect the output of a Gain block to the input of a Display block.
add_block('simulink/Math Operations/Gain', 'model/Gain'); add_block('simulink/Sinks/Display', 'model/Display'); add_line('model', [1], 'Display/1', 'autorouting', 'on');
The output port of the Gain block is port 1, so we connect 'Gain/1' to the Display input.
Fix the error in the code to correctly connect a Sum block output to a Scope input.
add_block('simulink/Math Operations/Sum', 'model/Sum'); add_block('simulink/Sinks/Scope', 'model/Scope'); add_line('model', 'Sum/1', [1], 'autorouting', 'on');
The Sum block output is port 1, and the Scope input is port 1, so connect 'Sum/1' to 'Scope/1'. The code already has 'Sum/1' as source, so the destination must be 'Scope/1'.
Fill both blanks to connect a Product block output to a Scope input and enable autorouting.
add_block('simulink/Math Operations/Product', 'model/Product'); add_block('simulink/Sinks/Scope', 'model/Scope'); add_line('model', [1], [2], 'autorouting', 'on');
The output port of the Product block is port 1, and the Scope input port is 1, so connect 'Product/1' to 'Scope/1'.
Fill all three blanks to create a dictionary mapping block names to their output ports, filtering only those with output port number greater than 1.
output_ports = { [1]: [2] for [3] in blocks if [2] > 1 }This dictionary comprehension maps each block's name to its output port, but only includes blocks where the output port number is greater than 1.
