InterviewStack.io LogoInterviewStack.io

Python Fundamentals and Core Syntax Questions

Comprehensive knowledge of core Python language features and syntax, including primitive and composite data types such as integer numbers, floating point numbers, strings, booleans, lists, dictionaries, sets, and tuples. Candidates should understand variable assignment and naming, operators for arithmetic, logical, and comparison operations, and control flow constructs including conditional statements and loops. Expect familiarity with function definition, invocation, parameter passing, return values, and scope rules, as well as common built in functions and idioms such as iteration utilities, list comprehensions, generator expressions, and basic functional utilities like map and filter. Candidates should demonstrate error and exception handling techniques and best practices for writing readable and maintainable code with modularization and clear naming. Practical skills include file input and output, working with common data formats such as comma separated values and JavaScript Object Notation, selecting appropriate data structures with attention to performance and memory characteristics, and applying memory efficient patterns for processing large data sets using iterators and generators. Familiarity with the standard library and common utilities for parsing and transforming data, and the ability to write small code snippets to solve algorithmic and data manipulation tasks, are expected.

MediumTechnical
0 practiced
Given a list of record dicts with keys 'id' and 'value', write a Python one-liner using map or filter (or both) that produces a list of tuples (id, normalized_value) where normalized_value = (value - min_value) / (max_value - min_value). Ensure safe handling when max_value equals min_value to avoid ZeroDivisionError.
HardTechnical
0 practiced
A nightly ETL takes 3 hours and you suspect Python code is the bottleneck. Describe a systematic approach to profile the script, list specific tools you would use (e.g., cProfile, line_profiler, memory_profiler), and enumerate code-level optimizations you might apply (algorithmic changes, data-structure swaps, and micro-optimizations).
HardTechnical
0 practiced
You implemented grouping over 10M event dicts using nested loops causing O(n^2) behavior. Describe and implement an efficient Python approach to compute per-user total and count in a single pass using appropriate data structures. Explain time and space complexity and discuss worst-case scenarios (e.g., extremely high cardinality).
HardTechnical
0 practiced
Implement merge_events(iterables) that takes multiple sorted iterables of event dicts (each sorted by the 'timestamp' key) and yields events in global timestamp order using heapq.merge or an equivalent streaming approach. Additionally, ensure duplicate event_ids are suppressed (the first occurrence wins) while streaming so memory stays as low as possible.
EasyTechnical
0 practiced
Given a list of dictionaries representing users, for example [{'id':1,'name':'A','status':'active'}, {'id':2,'name':'B'}], write a one-line Python list comprehension to extract ids of users with status 'active'. Show how to avoid KeyError when 'status' is missing.

Unlock Full Question Bank

Get access to hundreds of Python Fundamentals and Core Syntax interview questions and detailed answers.

Sign in to Continue

Join thousands of developers preparing for their dream job.