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.

EasyTechnical
0 practiced
You need to store millions of unique user IDs and perform fast membership checks and occasional iteration. Compare list, tuple, set, and dict for this use case in terms of membership-test complexity, iteration cost, and memory footprint. Which would you choose and why? Mention any memory-saving alternatives.
MediumTechnical
0 practiced
Write Python 3 code that reads a large NDJSON file and writes a standard JSON array to an output file without loading all objects into memory. Ensure proper JSON formatting (commas between items, no trailing comma). Discuss how to make the write atomic and how to test this behavior.
HardTechnical
0 practiced
Implement top_k_frequent(iterable, k) in Python 3 that returns the k items with highest frequency along with counts. Provide an exact solution that works when unique key count fits in memory and then describe approximate strategies (e.g., Count-Min Sketch, lossy counting) when cardinality is too high. Explain time and memory trade-offs.
HardTechnical
0 practiced
Implement streaming_histogram(iterable, num_bins) in Python 3: compute histogram bin edges and counts from a stream of numeric values without storing all values in memory. Describe a two-pass approach (estimate min/max then count) and single-pass alternatives (e.g., t-digest or adaptive bins), and discuss accuracy trade-offs with heavy-tailed distributions.
EasyTechnical
0 practiced
Write a Python 3 function parse_numbers(strings) that accepts an iterable of numeric strings which may include commas as thousands separators, optional currency symbols, and empty or invalid entries. Return a list of floats for successfully parsed values and return the number of failures. The function should be robust and efficient for large iterables and should not stop on the first error.

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.