0% found this document useful (0 votes)
25 views2 pages

Python Interview QA TI

The document contains a series of Python interview questions and answers related to automation scripts used during a Texas Instruments internship. Key topics include the use of libraries for file handling and data processing, handling large log files, debugging techniques, and best practices for writing maintainable and portable code. Additionally, it covers the use of regex for parsing logs, timestamp handling, and integration of scripts into workflows.

Uploaded by

sanshil685
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
25 views2 pages

Python Interview QA TI

The document contains a series of Python interview questions and answers related to automation scripts used during a Texas Instruments internship. Key topics include the use of libraries for file handling and data processing, handling large log files, debugging techniques, and best practices for writing maintainable and portable code. Additionally, it covers the use of regex for parsing logs, timestamp handling, and integration of scripts into workflows.

Uploaded by

sanshil685
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Python Interview Questions – Based on Texas

Instruments Internship
Q: Which Python libraries did you use in your automation scripts?
A: I used Python's built-in libraries such as re (regex) for pattern matching, csv for structured output,
argparse for command-line argument parsing, os and sys for file handling and path management,
and datetime for timestamp processing. I also used pandas for certain tabular data processing
tasks when analyzing large CSV reports.

Q: How do you handle very large log files in Python without running out of memory?
A: I use a streaming approach by reading files line-by-line using a for loop or iterators instead of
loading the entire file into memory. I also use compiled regex patterns for faster matching and break
early when the required data is found.

Q: What is the benefit of using 'with open(...) as file' in Python?


A: It ensures that files are properly closed after their block of code is executed, even if an error
occurs. It makes code cleaner and less error-prone compared to manually opening and closing
files.

Q: How did you parse Tarmac trace logs in your scripts?


A: I used regex to search for patterns corresponding to PUSH/POP instructions, memory writes, or
function calls. Each line was scanned for specific keywords or address formats, and matching lines
were processed to extract register names, values, and timestamps.

Q: What is argparse and how did you use it?


A: Argparse is a Python module for parsing command-line arguments. I used it to allow users to
pass parameters like test names, log file paths, or output CSV file names when running my scripts.

Q: How did you generate CSV reports from your Python scripts?
A: I used Python's csv.writer to create CSV files, writing each row as a list of values. In some cases,
I used pandas.DataFrame.to_csv for more complex tabular outputs.

Q: How do you optimize Python scripts for performance when processing logs?
A: I minimize function calls in tight loops, use list comprehensions where possible, compile regex
patterns beforehand, and use dictionaries for fast lookups instead of repeated list searches.

Q: How did you debug your Python scripts during development?


A: I used print statements for quick checks, Python's built-in logging module for structured logs, and
pdb (Python debugger) for stepping through execution when needed.

Q: How can you make Python scripts portable across different environments?
A: By avoiding hard-coded paths, using os.path.join for file paths, and checking for dependencies
before execution. I also wrote scripts to work with both Python 3.6+ versions.

Q: How do you handle errors in Python scripts?


A: I use try-except blocks to catch and handle exceptions gracefully, logging the error details and
continuing execution when possible, instead of crashing the program.

Q: What are some file handling best practices in Python?


A: Always use 'with open' for automatic closing, specify the correct encoding when reading/writing
text files, and check if files exist before attempting to open them.

Q: How do you test Python scripts for correctness?


A: I create small, controlled log files with known results and verify that my scripts produce the
expected output. I also compare results with manual calculations for validation.

Q: How did you modularize your code for maintainability?


A: I split the scripts into functions for specific tasks, placed common utilities in separate helper files,
and documented each function with docstrings.

Q: How did you ensure your Python scripts worked for multiple ARM cores?
A: I used configuration files or dictionaries mapping core types (CM0+, CM3, CM33) to their specific
settings, avoiding code duplication.

Q: Can you explain how regex helped in your automation tasks?


A: Regex allowed me to match specific instruction formats, memory addresses, and register names
in large text logs without manually parsing each line character-by-character.

Q: How do you handle timestamp comparisons in Python?


A: I parse timestamps as datetime objects or integers representing cycles, then subtract them to
compute durations.

Q: How did you integrate your Python scripts into the SoC DV workflow?
A: I wrote post-processing scripts that ran automatically after simulation, triggered by test
configuration files, so engineers didn’t have to run them manually.

Q: What are lambda functions and did you use them?


A: Lambda functions are small anonymous functions defined with the lambda keyword. I
occasionally used them for quick inline sorting or filtering of parsed data.

Q: What is the difference between '==' and 'is' in Python?


A: '==' checks for value equality, while 'is' checks for object identity (whether two variables point to
the same object in memory).

You might also like