Microsoft Python Interview Questions 2026

Published July 22, 2026 · Updated July 22, 2026

5 real Python interview questions asked at Microsoft. Upvoted by engineers who cleared the loop. Covers Technical, Screening, Scenario rounds.

5 questions
198 engineers asked
288 upvotes
Company: Microsoft
Technology: Python

All Python Questions Asked at Microsoft

Microsoft Medium Technical round JavaC#Python

Given a binary tree, print nodes level by level (BFS traversal). Then modify it to print alternate levels in reverse order (zigzag traversal). Analyse time and space complexity.

↑ 61 upvotes · 40 engineers asked this · SDE1
Microsoft Hard Technical round JavaPythonC#

Given a 2D grid of 0s and 1s, count the number of islands. Then extend: find the largest island, and then explain how you would solve this for a streaming grid that changes in real time using a Union-Find structure.

↑ 54 upvotes · 34 engineers asked this · SDE2
Microsoft Easy Screening round JavaC#Python

Find all pairs in an array that sum to a given target value. Explain the HashSet approach for O(n) time, handle duplicate pairs correctly, and discuss edge cases (negative numbers, empty array).

↑ 55 upvotes · 37 engineers asked this · SDE1
Microsoft Hard Scenario round 4–7 YearsLLMPython

You are building an AI agent that books travel. It has access to 6 tools. How do you prevent it from calling tools in the wrong order or entering infinite loops?

↑ 98 upvotes · 76 engineers asked this · AI Engineer
Microsoft Medium Technical round 2-5 yearsPython

Write a Python decorator @timed that prints how long a function took to execute, and explain how functools.wraps prevents it from breaking introspection.

↑ 20 upvotes · 11 engineers asked this · Senior SDE

Practice these questions with AI feedback

Get instant grading on your answers, identify your weak areas, and generate a personalised 14-day study plan — all free.

Build my study plan →

More Microsoft Questions

Microsoft C# Questions

Python Questions at Other Companies

Amazon Python Questions Google Python Questions Meta Python Questions

Browse by company

Amazon Google Microsoft Flipkart Swiggy Meta Apple Netflix Uber Airbnb Stripe Razorpay PhonePe Paytm Zomato Salesforce Oracle Adobe LinkedIn Atlassian Accenture Deloitte Wipro Infosys TCS Capgemini PayU General Anthropic OpenAI TikTok JPMorgan Walmart Spotify DoorDash Goldman Sachs Revolut Canva Capital One Lyft SAP Siemens Shopify Grab Cognizant LTIMindtree Myntra Hotstar Twitter Snowflake

Frequently asked questions

Given a binary tree, print nodes level by level (BFS traversal). Then modify it to print alternate levels in reverse order (zigzag traversal). Analyse time and space complexity.
Given a binary tree, print nodes level by level (BFS traversal). Then modify it to print alternate levels in reverse order (zigzag traversal). Analyse time and space complexity.
Given a 2D grid of 0s and 1s, count the number of islands. Then extend: find the largest island, and then explain how you would solve this for a streaming grid that changes in real time using a Union-Find structure.
Given a 2D grid of 0s and 1s, count the number of islands. Then extend: find the largest island, and then explain how you would solve this for a streaming grid that changes in real time using a Union-Find structure.
Find all pairs in an array that sum to a given target value. Explain the HashSet approach for O(n) time, handle duplicate pairs correctly, and discuss edge cases (negative numbers, empty array).
Find all pairs in an array that sum to a given target value. Explain the HashSet approach for O(n) time, handle duplicate pairs correctly, and discuss edge cases (negative numbers, empty array).
You are building an AI agent that books travel. It has access to 6 tools. How do you prevent it from calling tools in the wrong order or entering infinite loops?
You are building an AI agent that books travel. It has access to 6 tools. How do you prevent it from calling tools in the wrong order or entering infinite loops?
Write a Python decorator @timed that prints how long a function took to execute, and explain how functools.wraps prevents it from breaking introspection.
Write a Python decorator @timed that prints how long a function took to execute, and explain how functools.wraps prevents it from breaking introspection.