0% found this document useful (0 votes)
7 views5 pages

Python Developer Assessment Guide

The document outlines a comprehensive Python developer assessment consisting of six questions covering logic programming, MySQL query optimization, file operations, recursive functions, data structures, and memory management. Candidates are instructed to complete the assessment within one hour without using online resources, and their answers will serve as a basis for discussion during the interview. Each question requires specific programming tasks or explanations related to Python and database operations.

Uploaded by

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

Python Developer Assessment Guide

The document outlines a comprehensive Python developer assessment consisting of six questions covering logic programming, MySQL query optimization, file operations, recursive functions, data structures, and memory management. Candidates are instructed to complete the assessment within one hour without using online resources, and their answers will serve as a basis for discussion during the interview. Each question requires specific programming tasks or explanations related to Python and database operations.

Uploaded by

shubham.ravi9313
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

Comprehensive Python Developer Assessment

Duration: 1 hour
Instructions:
1. You can download this assessment document, edit and submit with your answers in
the format shown below.
2. Do not use google and any online help to answer.
3. Answers that you provide, will be a baseline for discussion during the interview.
4. Attempting answers to all questions is mandatory.

Name of the Candidate:

Total Experience:

Question 1 (Logic - Programming):

Scenario: Write a Python program for a given logic.

Task: We have 2 variables, variable1 and variable2. Please find the index of the sub-string
occurrence. Prepare the custom logic and Avoid using inbuilt functions.

Input: variable1 = "gifts are good to hold",


variable2= "good"
Output: 10
Explanation: "good" occurs at index 10.
Question 2 (MySQL - Query Optimization):

Scenario: Query optimizations.

Task: Optimize the following query with clear explanation:

select * from emp


where department_id in
(select id from department
where city in
(select city from cities) )

Question 3 (File Operations) :


Scenario: Perform file read/write operations.

Task: Write a python program, that reads the file [Link] and return the following
output:

Input: [Link]

EmployeeID Salary Department

1SB001 10,00,000 Development

1SB002 20,00,000 Business

1SB003 10,00,000 Development

1SB004 30,00,000 Sales

1SB005 10,00,000 Business

1SB006 50,00,000 Development

Output:
Department TotalEmployee HighestSalary
Development 3 50,00,000
Business 2 20,00,000
Sales 1 30,00,000

Question 4 (Recursive function - Python):


Write a logic to Find the list of prime numbers for the range for 30 using a recursive function.

Question 5 (Python Data Structure):

Write code snippets to hold below given diagram data/Nodes in python data structure.

Note:
● Please make a note we can extend this below tree till Nth level.
● Make sure easy traversing/Searching should be possible with your provided solution.
Question 6: Describe the memory management in python ? How python will handle the
memory management in below 5 scenarios.

1. Var1 = [1, 2, 3]
2. Var2 = Var1
3. [Link](4)
4. Var2 = (1, 2)
5. Var2[0] = 3

Common questions

Powered by AI

A recursive function to list prime numbers up to 30 involves checking each number for primality using a helper function that tests divisibility recursively. Start by defining a function `is_prime` that checks divisibility from 2 up to the square root of the number. Then, create a driver function that initializes a list and incrementally tests numbers, invoking `is_prime`, and collecting those that are prime until 30, employing recursive calls to continue checking each number.

Python manages memory using reference counting and garbage collection. For example, `Var1 = [1, 2, 3]` creates a list object referenced by Var1. When `Var2 = Var1` is executed, Var2 references the same list; no new copy is made. When `Var1.append(4)` is called, the list object is modified directly. However, reassigning `Var2 = (1, 2)` makes Var2 reference a new tuple object. Attempting `Var2[0] = 3` would raise an error, as tuples are immutable. Each step involves creating new objects or modifying existing ones, which Python handles efficiently.

When optimizing a SQL query that involves nested subqueries filtering employees based on the city, consider transforming the query to join operations which often perform better than nested subqueries. For instance, use INNER JOINS to connect the emp, department, and cities tables and filter directly on the city column, reducing unnecessary subquery computations. Also, ensure that appropriate indexes exist on the columns used in the JOINs and WHERE filters to enhance query performance.

To implement a custom Python logic that finds the index of a substring occurrence, you can iterate through the main string and compare segments of it to the substring manually. For each starting point in the main string, extract a segment of the same length as the substring and then compare it character by character to the substring. If a match is found, return the current starting index. This avoids the use of built-in functions like `str.find()` or `str.index()`.

To implement a scalable data structure for traversing a tree diagram, use classes to represent nodes and the tree itself. Create a `Node` class with properties for storing data and child nodes, and a `Tree` class with methods for adding nodes, performing traversal (like BFS or DFS for easy searching). Implement methods that can dynamically extend the tree structure, maintaining references to children nodes, ensuring optimal performance even as it scales to Nth levels.

To compute and display the total number of employees and highest salary per department, first read the CSV file using Python's `csv.reader` to parse data row-by-row. Use a dictionary to keep track of each department's employee count and the highest salary encountered. As you iterate through each row, update the dictionary by incrementing the employee count and comparing salaries to update the highest salary if necessary. Finally, format the output for each department showing the total employees and highest salary.

You might also like