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
Write a robust Python function parse_number(s) that converts common numeric strings such as '1,234.56', '$1.2M', '3.4e3', 'NaN', or empty string to floats or None. Explain how you would test locale differences and edge formatting scenarios.
MediumTechnical
0 practiced
Using itertools, implement chunked(iterable, n) that yields successive chunks of up to n items as lists from any iterable. Ensure your implementation does not read the whole iterable into memory and works with generator inputs.
HardTechnical
0 practiced
Write a Python function external_merge_sort(file_paths, output_path, key_index=0) that performs an external merge sort across multiple large CSV files that do not fit into memory. Describe how to split files into sorted chunks, write temporary files, perform a k-way merge (using heapq.merge or similar), and clean up temporary files safely.
MediumTechnical
0 practiced
Explain the role and benefits of type annotations in Python. For a data science codebase, discuss how annotations combined with tools like mypy and runtime checks can improve maintainability, reduce bugs, and help with refactoring.
HardTechnical
0 practiced
Write a decorator memoize_bounded(maxsize, persistence_file=None) in Python that caches function results with LRU eviction up to maxsize. If persistence_file is provided, persist the cache to disk on program exit (using shelve) and reload at decorator initialization. Discuss serialization limits and thread-safety.

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.