Complete the code to create a dynamic task inside the DAG using a loop.
for i in range(3): task = PythonOperator(task_id=f'task_[1]', python_callable=my_function, dag=dag)
The variable i is used in the loop to generate unique task IDs dynamically.
Complete the code to add tasks to the DAG dynamically using a loop and list comprehension.
tasks = [PythonOperator(task_id=f'task_[1]', python_callable=my_function, dag=dag) for [1] in range(5)]
The loop variable i is used inside the list comprehension to create multiple tasks with unique IDs.
Fix the error in the dynamic task creation loop by completing the missing part.
for i in range(3): task = PythonOperator(task_id=f'task_[1]', python_callable=my_function, dag=dag) task.set_downstream(next_task)
The loop variable i must be used to create unique task IDs to avoid task ID conflicts.
Fill both blanks to create tasks dynamically and set dependencies between them.
tasks = [] for [1] in range(3): task = PythonOperator(task_id=f'task_[1]', python_callable=my_function, dag=dag) tasks.append(task) for i in range(2): tasks[i].[2](tasks[i+1])
set_upstream instead of set_downstream for dependencies.The loop variable i is used to create unique task IDs and set_downstream sets the order of task execution.
Fill all three blanks to create a dictionary of tasks dynamically with conditions.
tasks = {f'task_[1]': PythonOperator(task_id=f'task_[1]', python_callable=my_function, dag=dag) for [2] in range(5) if [3] % 2 == 0}The variable i is used for task IDs and loop iteration, and the condition filters even numbers.