0
0
Apache Airflowdevops~10 mins

Sharing data between tasks effectively in Apache Airflow - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to push data from one task to XCom in Airflow.

Apache Airflow
def push_function(ti):
    ti.[1](key='sample_key', value='Hello from task')
Drag options to blanks, or click blank then click option'
Apush_xcom
Bxcom_push
Cxcom_pull
Dsend_xcom
Attempts:
3 left
💡 Hint
Common Mistakes
Using xcom_pull instead of xcom_push to send data.
Using incorrect method names like push_xcom or send_xcom.
2fill in blank
medium

Complete the code to pull data from XCom in Airflow.

Apache Airflow
def pull_function(ti):
    value = ti.[1](key='sample_key', task_ids='push_task')
    print(value)
Drag options to blanks, or click blank then click option'
Axcom_push
Bget_xcom
Cpull_xcom
Dxcom_pull
Attempts:
3 left
💡 Hint
Common Mistakes
Using xcom_push instead of xcom_pull to get data.
Using incorrect method names like pull_xcom or get_xcom.
3fill in blank
medium

Complete the code to push data to XCom in Airflow.

Apache Airflow
def push_function(ti):
    ti.[1]('sample_key', 'Data to share')
Drag options to blanks, or click blank then click option'
Axcom_push
Bxcom_pull
Cpush_xcom
Dsend_xcom
Attempts:
3 left
💡 Hint
Common Mistakes
Using xcom_pull instead of xcom_push to send data.
Using incorrect method names like push_xcom or send_xcom.
4fill in blank
hard

Fill both blanks to create a dictionary comprehension that shares only even numbers via XCom.

Apache Airflow
result = {num: num[1]2 for num in range(1, 6) if num [2] 2 == 0}
Drag options to blanks, or click blank then click option'
A**
B%
C//
D+
Attempts:
3 left
💡 Hint
Common Mistakes
Using incorrect operators like + or // in the comprehension.
Using wrong condition to filter even numbers.
5fill in blank
hard

Fill all three blanks to create a dictionary comprehension that shares uppercase keys with values greater than zero via XCom.

Apache Airflow
result = { [1]: [2] for [3], v in data.items() if v > 0}
Drag options to blanks, or click blank then click option'
Ak.upper()
Bv
Ck
Dv.upper()
Attempts:
3 left
💡 Hint
Common Mistakes
Using v.upper() which is invalid if values are not strings.
Mixing up keys and values in the comprehension.