r/learnAIAgents • • 4h ago

AI Engineer Interview Series | Part 03/10

4 Upvotes

🐍 Think Python coding is easy because you're working in GenAI?

Think again!

Here are 5 practical Python coding questions from my AI/ML technical interview preparation across companies like PwC, Cognizant, Deloitte, Ascendion and Hexaware.

Try solving these without using ChatGPT!

Q1. Second Largest Element

Given a list of integers, write a Python program to find the second-largest element without sorting the list.

What is the time complexity of your solution?

Q2. Longest Substring

Given a string, find the length of the longest substring without repeating characters.

Explain your approach and optimize the solution.

Q3. JSON Token Counting

Given a JSON file containing text, write a Python program to load the JSON and calculate the total number of tokens using an LLM tokenizer.

How would you handle large JSON files?

Q4. Python Decorators

What are decorators in Python?

Write a custom decorator to measure the execution time of a function. Explain why decorators are useful in real-world applications.

Q5. API Retries

Write a Python function to call an LLM API with retry logic.

How would you handle API failures, timeouts and rate-limit errors?

πŸ’‘ Interview Tip: Focus on writing clean code, explaining your logic and discussing time complexity. In AI Engineer interviews, practical Python knowledge matters just as much as GenAI concepts.

Save this reel and try solving all five questions.

Follow for Part 04!

#Python #PythonCoding #AIEngineer #CodingInterview #GenAI #PythonInterviewQuestions #MachineLearning #DataStructures #ProblemSolving #InterviewPreparation