Quick answer: Good forward deployed engineering practice problems cover the whole job: checking input, cleaning customer data, hiding private details, reading AI output safely, searching documents, retrying failed calls, estimating cost, testing results and controlling risky actions. The 15 problems here use plain Python and include two client scenarios, all with worked solutions.
These forward deployed engineering practice problems train the skills around an AI model. That is where much of the job lives: bad customer data, broken replies, failed calls and requests that are not clear.
There are 15 problems. The first 13 use plain Python, with no API key. The last two are client scenarios. If you want the background first, read our forward deployed engineer course guide.
How to use these forward deployed engineering exercises
Try each problem for 15 minutes before reading the answer. Then do three things:
- Run the solution on your computer.
- Add one input that might break it.
- Say in one sentence why a customer would care.
The third step turns coding practice into FDE practice. These are forward deployed engineering problems and solutions, but there is often more than one good answer. The code is kept small so you can see the main idea.
Pro tip: Save every answer in one GitHub project. Add a short note about the failure it prevents. You will have useful interview stories by the end.
Level 1: Clean and protect customer data
1. Find missing fields
A ticket must have a customer ID, subject and body. Return the fields that are missing or blank.
REQUIRED = ["customer_id", "subject", "body"]
def missing_fields(ticket):
missing = []
for field in REQUIRED:
value = ticket.get(field)
if value is None or str(value).strip() == "":
missing.append(field)
return missing
print(missing_fields({"customer_id": 0, "subject": " "}))
# ['subject', 'body']
Notice that the ID 0 is not called missing. A quick check such as if not value would reject it. Ask the client if zero is a valid ID before choosing the rule.
2. Make phone numbers match
The same Indian mobile number appears in several forms. Return one form, or None if it is not valid under this simple rule.
import re
def normalise_phone(raw):
digits = re.sub(r"\D", "", raw)
if len(digits) == 12 and digits.startswith("91"):
digits = digits[2:]
elif len(digits) == 11 and digits.startswith("0"):
digits = digits[1:]
if len(digits) == 10 and digits[0] in "6789":
return "+91" + digits
return None
print(normalise_phone("+91 90000-12345")) # +919000012345
print(normalise_phone("090000 12345")) # +919000012345
print(normalise_phone("12345")) # None
\D means any character that is not a digit. Returning None lets the next step send bad numbers to a person instead of guessing.
3. Keep the newest customer record
Two systems have the same email. Keep the record with the latest update date. Dates are in YYYY-MM-DD form.
def newest_records(records):
latest = {}
for record in records:
email = record["email"].strip().lower()
old = latest.get(email)
if old is None or record["updated"] > old["updated"]:
latest[email] = record
return list(latest.values())
rows = [
{"email": "ASHA@example.com", "city": "Guntur", "updated": "2026-01-10"},
{"email": "asha@example.com", "city": "Ongole", "updated": "2026-03-02"},
]
print([row["city"] for row in newest_records(rows)]) # ['Ongole']
Dates written in this order can be compared as text. Dates such as 02/03/2026 cannot. In a real project, ask which system the client trusts, because the newest row is not always the best one.
4. Hide emails and phone numbers
Before a message is sent to a model, replace emails and ten-digit mobile numbers.
import re
def hide_private(text):
text = re.sub(r"[\w.+-]+@[\w-]+\.[\w.-]+", "[EMAIL]", text)
return re.sub(r"(?<!\d)[6-9]\d{9}(?!\d)", "[PHONE]", text)
print(hide_private("Mail asha@example.com or call 9000012345 today"))
# Mail [EMAIL] or call [PHONE] today
The parts around the phone pattern make sure it is not inside a longer number. This is a first safety layer only. It will miss names, addresses and unusual formats, so real private data needs stronger controls.
Level 2: Make AI output safe to use
5. Read JSON from a messy reply
A model was asked for JSON, a text format for data, but added extra words. Return the data, or None if it cannot be read.
import json
def extract_json(reply):
start = reply.find("{")
end = reply.rfind("}")
if start == -1 or end < start:
return None
try:
return json.loads(reply[start:end + 1])
except json.JSONDecodeError:
return None
print(extract_json('Sure! {"team": "billing", "urgent": false} Done.'))
# {'team': 'billing', 'urgent': False}
print(extract_json("I am not sure")) # None
This repairs a common small mistake. If your model service supports structured output, use that too. Keep the check because the reply can still break your business rules.
6. Accept only allowed teams
A model may invent a team name. Send unknown labels to a person.
ALLOWED = {"billing", "technical", "general"}
def choose_team(result):
team = result.get("team")
if isinstance(team, str) and team.strip().lower() in ALLOWED:
return team.strip().lower()
return "human_review"
print(choose_team({"team": " Billing "})) # billing
print(choose_team({"team": "magic"})) # human_review
print(choose_team({"team": 7})) # human_review
The safe path is part of the design. "Human review" is better than silently sending a refund request to the wrong place.
7. Try a failed call again
Write a retry function that waits 1 second, then 2, then 4, and so on between failures. Pass in the sleep function so the code can be tested without waiting.
def retry(action, sleep, attempts=3):
for number in range(attempts):
try:
return action()
except TimeoutError:
if number == attempts - 1:
raise
sleep(2 ** number)
calls = {"count": 0}
waits = []
def flaky_call():
calls["count"] += 1
if calls["count"] < 3:
raise TimeoutError("slow service")
return "ok"
print(retry(flaky_call, waits.append)) # ok
print(waits) # [1, 2]
With three attempts there are only two waits. The last error is raised, so it is not hidden. Use this only for calls that are safe to repeat. A payment could be made twice if you retry it without extra protection.
Common mistake: Catching every error and trying again. A wrong password will still be wrong next time. Retry only errors that may go away, such as a timeout.
Level 3: Search and tools
8. Split text with overlap
Split a document into groups of words. Repeat a few words so an idea at the edge is less likely to be cut in half.
def chunk_words(text, size=5, overlap=2):
if overlap >= size:
raise ValueError("overlap must be smaller than size")
words = text.split()
chunks = []
step = size - overlap
for start in range(0, len(words), step):
chunks.append(" ".join(words[start:start + size]))
if start + size >= len(words):
break
return chunks
print(chunk_words("a b c d e f g h"))
# ['a b c d e', 'd e f g h']
The step is three words, so d e appears in both pieces. Real chunks are much larger and often follow headings or paragraphs. Test the size on your own documents.
9. Find the best help notes
Rank notes by how many query words they share. Break ties by note name.
import re
def words(text):
return set(re.findall(r"\w+", text.lower()))
def search(query, notes, limit=2):
wanted = words(query)
scores = []
for name, text in notes.items():
score = len(wanted & words(text))
if score > 0:
scores.append((name, score))
return sorted(scores, key=lambda item: (-item[1], item[0]))[:limit]
notes = {
"refunds": "Refunds are paid within 7 days of approval",
"delivery": "Orders ship in 2 days",
"account": "Reset your password from settings",
}
print(search("How many days for refunds?", notes))
# [('refunds', 2), ('delivery', 1)]
The refund note shares days and refunds. Word matching is a useful first version, but it misses different words with the same meaning. Embeddings, which store meaning as numbers, can help with that. Compare both on real questions before adding more systems.
10. Ask before a risky action
An AI agent may look up orders by itself. Refunds need approval. Unknown tools must be blocked.
SAFE = {"find_order"}
NEEDS_APPROVAL = {"issue_refund"}
def check_tool(name, approved=False):
if name in SAFE:
return "run"
if name in NEEDS_APPROVAL:
return "run" if approved else "ask_human"
return "block"
print(check_tool("find_order")) # run
print(check_tool("issue_refund")) # ask_human
print(check_tool("delete_all_orders")) # block
This list is in code, so the model cannot talk its way around it. The approval value must come from your trusted app, not from text made by the model.
Level 4: Measure the system
11. Score the search results
For each question you know the correct note. Find how often it appears in the returned list. This measure is called the hit rate.
def hit_rate(cases):
hits = 0
for case in cases:
if case["expected"] in case["found"]:
hits += 1
return hits / len(cases) if cases else 0.0
cases = [
{"expected": "refunds", "found": ["refunds", "delivery"]},
{"expected": "account", "found": ["delivery", "refunds"]},
{"expected": "delivery", "found": ["account", "delivery"]},
{"expected": "refunds", "found": ["refunds"]},
]
print(f"{hit_rate(cases):.0%}") # 75%
Three of the four searches found the right note. If search fails, changing the answer prompt may not help. Measure search and answers separately.
12. Find newly broken tests
Your new prompt gets the same total score, but did it break something that worked? Compare results by test ID.
def newly_broken(before, after):
broken = []
for case_id, passed in before.items():
if passed and not after.get(case_id, False):
broken.append(case_id)
return sorted(broken)
before = {"q1": True, "q2": False, "q3": True}
after = {"q1": True, "q2": True, "q3": False}
print(newly_broken(before, after)) # ['q3']
Both versions pass two tests, so the total hides the change. Missing results count as failures. If q3 is about patient safety, this release should not go out.
13. Estimate model cost
Work out daily and 30-day cost. Models charge by tokens, which are small pieces of text. Prices are inputs because real prices change.
def model_cost(requests, tokens_in, tokens_out, price_in, price_out):
input_cost = requests * tokens_in / 1_000_000 * price_in
output_cost = requests * tokens_out / 1_000_000 * price_out
return input_cost + output_cost
daily = model_cost(1000, 1500, 300, price_in=2, price_out=8)
print(f"Daily: {daily:.2f}; 30 days: {daily * 30:.2f}")
# Daily: 5.40; 30 days: 162.00
The example prices are made up, per million tokens. Input costs 3.00 and output costs 2.40. Ask the client how much the tool will be used, and test a busy month as well as a normal one.
Client scenario practice
14. "We want an AI chatbot"
Problem: A clinic manager says only this. Write the first six questions you would ask.
One good answer:
- Who will use it: patients, staff or both?
- What task takes the most time today?
- Which answers could harm someone if they were wrong?
- Where is the trusted information, and who updates it?
- What private data is involved, and who may see it?
- What number should improve after one month?
A sensible first version may answer only opening hours and document rules, with a source. Medical advice should go to trained staff. You have made the problem smaller and safer before choosing any tool.
15. The client changes the goal
Problem: You are building a tool that drafts replies. Two days before the demo, the client asks it to send them without review. What do you say?
One good answer: "We can add sending, but it changes the risk. Our tests check draft quality, not safe sending. For this demo, let us keep human approval and record each correction. If the error rate meets the limit you choose, we can plan sending for low-risk messages next."
This answer does not just say no. It explains the risk, keeps the demo date and offers a next step.
Interview note: In a scenario round, do not rush to fill silence with tool names. Ask, agree on success, start small and explain how you would test it.
How to turn this coding practice into a project
Use this forward deployed engineering coding practice as building blocks:
| Project part | Problems |
|---|---|
| Accept and clean a message | 1, 2, 3, 4 |
| Read and check model output | 5, 6, 7 |
| Find help notes | 8, 9, 11 |
| Use actions safely | 10 |
| Test and plan the release | 12, 13 |
| Explain it to a client | 14, 15 |
Build the flow in our FDE tutorial, then prepare with the FDE interview questions. If your basics need work, go back to Python practice. The FDE roadmap shows the next stage. Students in any Andhra Pradesh or Telangana city can also learn with us live online.
Frequently asked questions
Do I need an AI API key for these problems?
No. All 13 coding problems use only Python's built-in tools. They practise the code around a model, such as checks, retries, search and tests.
How good should my Python be before I start?
You should know functions, loops, lists, dictionaries and basic error handling. If those are hard, solve basic Python problems first and then return.
Are these questions asked in FDE interviews?
Interview tasks vary by company. Data cleaning, API failures, AI output checks, testing and unclear client requests are sensible topics to practise for this role.
How many problems should I solve in a day?
One or two is enough. Solve it, test bad input, then explain your choice aloud. The explanation is part of the practice.
What should I build after finishing the problems?
Join several solutions into one small support tool. Clean the messages, remove private details, search help notes, return a checked answer and measure it on a test set.
Want feedback on how you solve problems like these? Book a free demo class, live online or in Madhapur, or explore the Forward Deployed AI Engineer programme.
