Bird
0
0

Which of the following is the correct way to create a RunnableLambda that doubles a number input?

easy📝 Syntax Q12 of 15
LangChain - Chains and LCEL
Which of the following is the correct way to create a RunnableLambda that doubles a number input?
ARunnableLambda(lambda x: x + 2)
BRunnableLambda(lambda x: x * 2)
CRunnableLambda(lambda x: x / 2)
DRunnableLambda(lambda x: x - 2)
Step-by-Step Solution
Solution:
  1. Step 1: Identify the doubling function

    Doubling means multiplying the input by 2, so the function should be lambda x: x * 2.
  2. Step 2: Match with options

    RunnableLambda(lambda x: x * 2) matches the doubling function exactly; others perform addition, division, or subtraction.
  3. Final Answer:

    RunnableLambda(lambda x: x * 2) -> Option B
  4. Quick Check:

    Doubling function uses multiplication by 2 = D [OK]
Quick Trick: Doubling means multiply input by 2 in lambda [OK]
Common Mistakes:
  • Using addition instead of multiplication
  • Confusing division or subtraction for doubling
  • Incorrect lambda syntax

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More LangChain Quizzes