Skip to content

LangChain Practice Exam

Test yourself under real exam conditions: 50 timed questions, 60 on the clock, pass mark 70%%. Instant score with a full review of everything you got wrong. Free — no account needed.

📝 50 questions · ⏱ 60 minutes · 🎯 Pass mark 70% · 🆓 Free, no signup

Exam details

  • 50 questions drawn from 166 cards
  • Countdown timer — auto-submits when time runs out
  • Pass mark 70% (real certification threshold)
  • Full review of wrong answers at the end
  • No signup required — save your score with a free account

Sample Questions

5 shown

What is LangChain?

Show ▼

LangChain is an open-source Python framework for building applications powered by large language models (LLMs). It provides modular components for prompts, chains, agents, memory, and retrieval to compose complex LLM workflows.

pip install langchain langchain-openai

What is LCEL (LangChain Expression Language)?

Show ▼

LCEL is a declarative syntax for composing LangChain components using the pipe operator (|). It creates RunnableSequence chains that support streaming, batching, and async out of the box.

from langchain_openai import ChatOpenAI
from langchain_core.prompts import ChatPromptTemplate
from langchain_core.output_parsers import StrOutputParser

chain = (
ChatPromptTemplate.from_template("Explain {topic} simply.")
| ChatOpenAI(model="gpt-4o")
| StrOutputParser()
)
result = chain.invoke({"topic": "recursion"})

How do you create a ChatPromptTemplate?

Show ▼

Use ChatPromptTemplate.from_messages() with a list of (role, template) tuples. Variables are wrapped in curly braces.

from langchain_core.prompts import ChatPromptTemplate

prompt = ChatPromptTemplate.from_messages([
("system", "You are a helpful {role}."),
("human", "{question}"),
])
messages = prompt.invoke({
"role": "tutor",
"question": "What is a linked list?"
})

How do you invoke a ChatModel in LangChain?

Show ▼

Instantiate the model class and call .invoke() with a list of messages or a prompt value. The model returns an AIMessage.

from langchain_openai import ChatOpenAI
from langchain_core.messages import HumanMessage

llm = ChatOpenAI(model="gpt-4o", temperature=0)
response = llm.invoke([
HumanMessage(content="What is LangChain?")
])
print(response.content)

How do you stream responses in LangChain?

Show ▼

Call .stream() instead of .invoke() on any Runnable. It returns an iterator of chunks you can process incrementally.

from langchain_openai import ChatOpenAI

llm = ChatOpenAI(model="gpt-4o")
for chunk in llm.stream("Tell me a joke"):
print(chunk.content, end="", flush=True)

🎯 Take the LangChain Practice Exam