Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to push a value to XCom in an Airflow task.
Apache Airflow
ti.[1](key='sample_key', value='hello')
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'pull' instead of 'xcom_push' to send data.
Using incorrect method names like 'push_xcom'.
✗ Incorrect
The method xcom_push is used to send data from one task to another in Airflow.
2fill in blank
mediumComplete the code to pull a value from XCom in an Airflow task.
Apache Airflow
value = ti.[1](key='sample_key', task_ids='task_a')
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'xcom_push' instead of 'xcom_pull' to get data.
Using incorrect method names like 'pull_xcom'.
✗ Incorrect
The method xcom_pull retrieves data sent by another task via XCom.
3fill in blank
hardFix the error in the code to correctly pull XCom data from a specific task.
Apache Airflow
result = ti.xcom_pull(key=[1], task_ids='task_b')
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Passing the key without quotes causing a NameError.
Passing the key as a list instead of a string.
✗ Incorrect
The key parameter must be a string, so it needs quotes. Double quotes or single quotes both work.
4fill in blank
hardFill both blanks to push and then pull a value using XCom in Airflow.
Apache Airflow
ti.[1](key='data', value=42) retrieved = ti.[2](key='data', task_ids='task_c')
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing up push and pull methods.
Using non-existent methods like 'push' or 'pull' alone.
✗ Incorrect
Use xcom_push to send data and xcom_pull to receive it.
5fill in blank
hardFill all three blanks to create a dictionary comprehension that pulls XCom values greater than 10.
Apache Airflow
results = {task_id: ti.[1](key='value', task_ids=task_id) for task_id in tasks if ti.[2](key='value', task_ids=task_id) [3] 10} Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using different methods for pulling data in the comprehension.
Using '<' instead of '>' for filtering.
✗ Incorrect
Use xcom_pull to get values and filter those greater than 10 with >.