Challenge - 5 Problems
Runnable Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ component_behavior
intermediate1:30remaining
What does RunnablePassthrough output?
Given a RunnablePassthrough instance in LangChain, what will be the output when you run it with input
"Hello"?LangChain
from langchain_core.runnables import RunnablePassthrough runnable = RunnablePassthrough() result = runnable.invoke("Hello") print(result)
Attempts:
2 left
💡 Hint
RunnablePassthrough returns exactly what it receives.
✗ Incorrect
RunnablePassthrough is designed to pass the input through unchanged. So invoking it with "Hello" returns "Hello".
📝 Syntax
intermediate1:30remaining
Which RunnableLambda syntax correctly doubles a number?
Select the correct RunnableLambda code that doubles the input number.
LangChain
from langchain_core.runnables import RunnableLambda
Attempts:
2 left
💡 Hint
Doubling means multiplying by 2.
✗ Incorrect
RunnableLambda takes a function. To double a number, the function should multiply input by 2.
❓ state_output
advanced2:00remaining
What is the output of this RunnableLambda chain?
Consider this code snippet using RunnableLambda and RunnablePassthrough. What is printed?
LangChain
from langchain_core.runnables import RunnableLambda, RunnablePassthrough passthrough = RunnablePassthrough() lambda_double = RunnableLambda(lambda x: x * 2) chain = passthrough | lambda_double result = chain.invoke(5) print(result)
Attempts:
2 left
💡 Hint
RunnablePassthrough passes input unchanged, then RunnableLambda doubles it.
✗ Incorrect
The chain first passes 5 unchanged, then doubles it to 10.
🔧 Debug
advanced2:00remaining
Why does this RunnableLambda code raise an error?
This RunnableLambda is defined as
RunnableLambda(lambda x: x[0]). What error occurs when invoking with input 10?LangChain
from langchain_core.runnables import RunnableLambda runnable = RunnableLambda(lambda x: x[0]) runnable.invoke(10)
Attempts:
2 left
💡 Hint
Check if the input type supports indexing.
✗ Incorrect
The input 10 is an integer and cannot be indexed, so accessing x[0] raises a TypeError.
🧠 Conceptual
expert2:00remaining
Which statement about RunnablePassthrough and RunnableLambda is true?
Choose the correct statement about RunnablePassthrough and RunnableLambda in LangChain.
Attempts:
2 left
💡 Hint
Think about what each class is designed to do with input.
✗ Incorrect
RunnablePassthrough simply returns the input as is. RunnableLambda applies a user-defined function to the input.