edit

Python Questionnaire

vers 1 updated on 07 Jul 2025 by ( bismay/ bismay)

Introduction

To categorize an incoming developer based on their Python knowledge and decide which week to start their training, we can design a Python Developer Placement Exam divided into 5 sections — each corresponding to a phase of your training plan.


Assessment Strategy

Each section will have 5–6 questions, mixing multiple-choice (MCQ), coding problems, and short-answer formats. Based on their performance in each section, you can map them to the appropriate starting week.

Section Focus Area Maps To Score Range (Out of 20)
A Python Basics Week 1–4 < 12 → Beginner
B OOP & Modules Week 5–6 < 12 → Intermediate
C Data Handling & Libraries Week 7–8 < 12 → Intermediate+
D Data Science/ML Week 9–13 < 12 → Data Science Track
E API & Backend Dev Week 14–17 < 12 → API Track

You can place a developer where they start scoring less than 12/20, indicating a knowledge gap.


Questions

SECTION A: Python Basics (Weeks 1–4)

Q1 (MCQ): What is the output of the following?

x = [1, 2, 3]
print(x[1:3])

A) [1, 2] B) [2, 3] C) [1, 2, 3] D) [3]

Q2 (Short): What’s the difference between a tuple and a list in Python?

A) Tuple is mutable, List is immutable B) Both are mutable C) Tuple is immutable, List is mutable D) Both are immutable

Q3 (MCQ): Which function checks if a string is a palindrome?

A) reverse_string( ) B) string == string[::-1] C) is_palindrome(string[::-1]) D) len(string) == 0

Q4 (MCQ): What does the strip( ) function do on a string?

A) Removes all spaces B) Removes trailing whitespace only C) Removes leading and trailing whitespace D) Removes tabs only

Q5 (Code): Write a loop that prints all even numbers from 1 to 10.


SECTION B: OOP, Modules, and Exception Handling (Weeks 5–6)

Q1 (MCQ): What is the output?

class A:
    def __init__(self, x):
        self.x = x

a = A(5)
print(a.x)

A) Error B) None C) 5 D) x

Q2 (MCQ): What is the difference between @staticmethod and @classmethod?

A) Both take self B) Static methods require object instantiation C) Class methods work only on instances D) Static methods don’t take self, class methods take cls

Q3 (Code): Create a class Rectangle with a method area( ) that returns width * height.

Q4 (MCQ): Which of the following is a built-in Python exception?

A) ZeroDivisionError B) FileExistException C) ListEmptyError D) TypeConvertException

Q5 (Code): Write a try-except block that catches a ZeroDivisionError.


SECTION C: Data Handling and Libraries (Weeks 7–8)

Q1 (MCQ): What does df.groupby('column').mean( ) do in pandas?

A) Groups and sums values B) Groups and averages values by column C) Filters nulls D) Adds column values

Q2 (Short): Describe what NumPy is used for in one sentence.

A) Numerical computation and multi-dimensional arrays B) Text parsing C) Web scraping D) Handling CSVs

Q3 (Code): Load a CSV file using pandas and print the first 5 rows.

Q4 (MCQ): Which function is used to draw a line plot in matplotlib?

A) bar( ) B) plot( ) C) hist( ) D) scatter( )

Q5 (Code): Given a list of numbers, convert it into a NumPy array and find the mean.


SECTION D: Data Science & ML (Weeks 9–13)

Q1 (MCQ): What does train_test_split do?

A) Trains the model B) Splits dataset into training and test sets C) Validates model D) Combines datasets

Q2 (Short): What is the difference between supervised and unsupervised learning?

A) Supervised learns from patterns only B) Unsupervised uses labels C) Supervised uses labels, unsupervised does not D) Both require labeled data

Q3 (Code): Write a simple linear regression model using scikit-learn.

Q4 (MCQ): Which of the following is a clustering algorithm?

A) Logistic Regression B) Decision Tree C) K-Means D) SVM

Q5 (Code): Use pandas to check for missing values in a dataset.


SECTION E: API & Backend Development (Weeks 14–17)

Q1 (MCQ): What HTTP method is used to retrieve data from a server?

A) POST B) GET C) PUT D) DELETE

Q2 (Short): What is the difference between PUT and POST methods?

A) POST creates; PUT updates or creates (idempotent) B) PUT is used only for DELETE C) POST deletes files D) POST is always faster than PUT

Q3 (Code): Write a minimal Flask API with one route /hello returning "Hello, world!"

Q4 (Code): How do you connect to a PostgreSQL database in Python using SQLAlchemy?

Q5 (MCQ): What is JWT used for?

A) Password encryption B) Logging errors C) Stateless authentication D) Database migration

Answer Key Summary

Section Question Correct Option Answer Description
A Q1 B [2, 3]
A Q2 C Tuple = immutable
A Q3 B Reverse string check
A Q4 C Strip leading & trailing spaces
A Q5 C Loop with condition
B Q1 C Output: 5
B Q2 D static vs class methods
B Q3 A Area = width * height
B Q4 A Built-in exception
B Q5 C Catch & print error
C Q1 B Group and mean
C Q2 A Numerical arrays
C Q3 C read_csv + head
C Q4 B plot( ) for line
C Q5 B np.array( ).mean( )
D Q1 B Splits data
D Q2 C Labels vs no labels
D Q3 D scikit-learn
D Q4 C K-Means
D Q5 C isnull( ).sum( )
E Q1 B GET = retrieve
E Q2 A POST vs PUT
E Q3 C "Hello, world!"
E Q4 A create_engine( )
E Q5 C Stateless auth