Skip to content
1. Python Basics
- Write a Python program to reverse a string.
- How do you find the factorial of a number using recursion?
- Write a program to check if a number is prime.
- Find the second largest element in a list.
- Print only duplicate characters in a string.
- Explain difference between
is
and ==
in Python.
- What are Python decorators? Give a simple example.
- What is list comprehension? Write one example.
- Explain mutable vs immutable with examples.
- What are Python generators? Write a generator for Fibonacci numbers.
2. Python OOPs
- What is the difference between
@staticmethod
, @classmethod
, and normal methods?
- Write a class
Car
with attributes brand, model, year and a method to display details.
- Explain multiple inheritance in Python with example.
- What is method overriding? Give an example.
- Difference between
__init__
and __new__
.
3. File Handling & Data
- Write a Python program to read a text file and count word frequency.
- How to read/write JSON files in Python? Give an example.
- Write code to extract email addresses from a text using regex.
- Can Python read PDFs? Write sample code.
- How to connect Python with SQL database (example with SQLite/MySQL)?
4. Testing with Python (Pytest & Selenium)
- Write a pytest test case for login functionality with email & password.
- Why do we use fixtures in pytest? Write a fixture to open & quit a browser.
- Difference between implicit wait and explicit wait in Selenium.
- Python Selenium → Take a screenshot of a webpage & save it locally.
- Write code to handle dynamic elements using XPath in Selenium.
- How do you select a value from a dropdown in Selenium (Python)?
- Explain handling cookies in Selenium with Python.
- Use ActionChains in Selenium to drag & drop an element.
- Write Python code to verify if a file is downloaded (without relying on browser).
- Can we read a PDF opened in browser with Selenium + Python? How?
5. API Testing with Python
- Write Python code using
requests
library to send a GET request & print status code.
- Write a POST request with JSON payload & print the response.
- How do you send headers with a request in Python? Example.
- How to assert response body in Python API tests?
- Explain difference between
response.text
and response.json()
.
6. Advanced Python (Practice)
- Write a Python program to implement multithreading.
- Explain difference between multiprocessing and multithreading.
- Write a function with
@lru_cache
decorator and explain caching.
- Write a Python script to send an email.
- Explain how you would test an ML model with Python.