D DevBrainBox

Python

Python Interview Questions and Answers

1. What is Python?

Python is a high-level, interpreted, and general-purpose programming language known for its readability and dynamic typing.

2. What are Python’s key features?

  • Easy to learn and read
  • Interpreted
  • Dynamically typed
  • Extensive standard libraries
  • Object-oriented and functional

3. What are Python’s data types?

  • Numeric: int, float, complex
  • Sequence: list, tuple, range
  • Text: str
  • Set: set, frozenset
  • Mapping: dict
  • Boolean: bool
  • NoneType: None

4. What is a dynamically typed language?

Variable types are determined at runtime.

5. What is PEP 8?

It is the style guide for writing clean and readable Python code.

6. What is the difference between is and ==?

  • is: compares identity
  • ==: compares values

7. How is memory managed in Python?

  • Through reference counting and garbage collection.

8. What is the difference between a list and a tuple?

  • List: mutable
  • Tuple: immutable

9. What is a dictionary in Python?

  • An unordered collection of key-value pairs:
data = `{"name": "John", "age": 30}`

10. How do you comment in Python?

Single line: # Comment Multi-line: """Comment""" or '''Comment'''

11. What are Python control structures?

if, elif, else, for, while, break, continue, pass

12. How to define a function in Python?

python def greet(name): return f"Hello, {name}"

13.W hat is a lambda function?

  • Anonymous function:
add = lambda x, y: x + y

14. What are *args and kwargs?

*args: variable-length positional arguments *kwargs: variable-length keyword arguments

15. What is recursion?

  • A function calling itself.

16. What is the purpose of return?

  • It ends the function and sends a result back.

17. What is pass?

  • A placeholder for future code.

18. What is the use of yield?

  • It turns a function into a generator.

19. What’s the difference between global and nonlocal?

  • global: refers to variables in the global scope
  • nonlocal: refers to variables in the enclosing scope

20. What is a docstring?

  • Documentation string used for functions, classes, or modules.

21. What is OOP?

  • Object-Oriented Programming, based on objects and classes.

22. What is a class?

  • A blueprint for creating objects.

23. What is an object?

  • An instance of a class.

24. What are __init__ and self?

  • __init__: constructor
  • self: refers to the instance itself

25. What is inheritance?

  • Reusing code from parent classes.

26. What is multiple inheritance?

  • A class inheriting from multiple classes.

27. What is encapsulation?

  • Hiding internal details using private members (_var, __var).

28. What is polymorphism?

  • Different classes having methods with the same name.

29. What are magic methods?

  • Special methods like __str__, __len__, __add__.

30. What is a class method and static method?

  • @classmethod: works with class, takes cls
  • @staticmethod: does not access class or instance data

31. How to open a file in Python?

f = open("file.txt", "r")

32. How to read/write a file?

  • Read: f.read()
  • Write: f.write("data")

33.. What is with open()?

  • It auto-closes files.
with open("file.txt") as f:
 data = f.read()

34. What is a module?

  • A Python file with functions and classes.

35. What is a package?

  • A directory containing __init__.pyandmodules`.

36. How to import a module?

import math
from os import path

37. How to list installed modules?

  • Use pip list

38. What is the difference between import and from?

  • import os vs from os import path

39. How to install packages?

  • pip install package_name

40. How to create a virtual environment?

python -m venv env

41. What is an exception?

An error that disrupts normal program flow.

42. How to handle exceptions?

try:
 # code
except Exception as e:
 print(e)

43. What is finally used for?

  • Executes code regardless of exception.

44. What is the use of raise?

  • To manually raise an exception.

45. Name some common exceptions.

  • ValueError, IndexError, TypeError, KeyError

46. What is assert?

  • Used to debug, raises AssertionError if condition is False.

47. How to debug in Python?

  • Using pdb or IDE debuggers.

48. What is traceback?

  • Error report showing where an exception occurred.

49. How to log errors?

  • Using the logging module.

50. What is the difference between error and exception?

  • Error: programming mistake
  • Exception: can be handled

51. What is a generator?

  • Function that returns an iterator using yield.

52. What is a decorator?

  • Function that modifies another function.
def decorator(func):
 def wrapper():
    print("Before")
    func()
    print("After")
 return wrapper

53. What are comprehensions?

  • Compact ways to create collections.
squares = [x*x for x in range(10)]

54. What is a context manager?

  • Object with __enter__ 1and exit` methods. Used in with.

55. What is a metaclass?

  • A class of a class.

56. What is duck typing?

  • Type checking based on behavior not inheritance.

57. What is monkey patching?

  • Changing a class or module at runtime.

58. What is GIL (Global Interpreter Lock)?

  • A lock that allows only one thread to execute at a time in CPython.

59. What is multithreading?

  • Running multiple threads concurrently.

60. What is multiprocessing?

  • Running code in multiple processes for true parallelis

61. What is a list?

  • Ordered, mutable collection.
[1, 2, 3]

62. What is a tuple?

  • Ordered, immutable collection.

63. What is a set?

  • Unordered, unique items.

64. What is a dictionary?

  • Key-value pairs.

65. How to merge two lists?

list1 + list2

66. How to sort a list?

  • sorted(list) or list.sort()

67. What is a shallow copy vs deep copy?

  • Shallow: one level deep
  • Deep: full recursive copy

68. How to reverse a list?

  • list[::-1] or list.reverse()

69. How to remove duplicates?

  • list(set(mylist))

70. How to iterate over a dictionary?

for key, val in dict.items():
 print(key, val)

71. What is NumPy used for?

  • Efficient numerical and matrix operations.

72. What is pandas?

  • Data manipulation library using DataFrames.

73. What is matplotlib?

  • For data visualization.

74. What is Flask?

  • A micro web framework.

75. What is Django?

  • A high-level full-stack web framework.

76. What is SQLAlchemy?

  • ORM for databases in Python.

77. What is pip?

  • Python package manager.

78. What is Jupyter Notebook?

  • Web-based IDE for interactive Python.

79. What is virtualenv?

  • Tool to create isolated Python environments.

80. What is pytest?

  • A testing framework.

81. What is slicing?

  • Extracting parts of strings, lists, etc.
s[1:4]

82. How to check Python version?

  • python --version

83. What is __name__ == "__main__" used for?

  • Entry point of a script.

84. What is list comprehension?

  • Compact list creation:
[x for x in range(5)]

85. What is the walrus operator :=?

  • Assignment expression inside conditions (Python 3.8+).

86. What are f-strings?

  • Formatted string literals:
f"Hello {name}"

87. How to convert string to int?

  • int("123")

88. How to convert int to string?

  • str(123)

89. What is a ternary operator?

x = a if condition else b

90. What is dir()?

  • Lists attributes of object.

91. Swap two variables.

a, b = b, a

92. Check if string is palindrome.

s == s[::-1]

93. Factorial using recursion.

def fact(n):
 return 1 if n==0 else n * fact(n-1)

94. Fibonacci series.

def fib(n):
    a, b = 0, 1
    for _ in range(n):
        print(a)
        a, b = b, a + b

95. Check for prime.

def is_prime(n):
 return n > 1 and all(n % i for i in range(2, int(n**0.5)+1))

96. Reverse a string.

s[::-1]

97. Sum of list.

sum([1, 2, 3])

98. Find max in list.

max([1, 2, 3])

99. List even numbers from list.

[x for x in list if x%2==0]

### 100. Count vowels in string.
```python
sum(1 for c in s if c in 'aeiouAEIOU')

101. How do you create a string in Python?

s = "Hello"

102. How do you concatenate strings?

"Hello" + " " + "World"

103. How to repeat a string 3 times?

"Hi" * 3  # Output: "HiHiHi"

104. How to find the length of a string?

len("Python")

105. How to convert to uppercase/lowercase?

s.upper(), s.lower()

106. How to check if a string starts/ends with a substring?

s.startswith("H"), s.endswith("d")

107. How to find a substring in a string?

s.find("lo")

108. How to replace part of a string?

s.replace("world", "Python")

109. How to split a string?

"one,two".split(",")

110. How to join a list into a string?

",".join(["a", "b"])

111. How to strip whitespace from a string?

s.strip(), s.lstrip(), s.rstrip()

112. How to check if string is digit?

s.isdigit()

113. How to reverse a string?

s[::-1]

114. What is a raw string?

  • A string with r"" to ignore escape sequences.

115. How to format a string with variables?

f"My name is {name}"

116. ### What does zfill() do?

  • Pads string on the left with zeros: "5".zfill(3) → "005"

117. How to count substrings?

s.count("a")

118. What is isalnum()?

  • Checks if string is alphanumeric.

119. How to center a string?

"Hello".center(10, "-")

120. What’s the difference between isalpha() and isdigit()?

  • isalpha(): checks for letters
  • isdigit(): checks for digits

121. How to add item to a list?

mylist.append(10)

122. How to insert item at specific index?

mylist.insert(2, 99)

123. How to remove an item by value?

mylist.remove(5)

124. How to remove an item by index?

mylist.pop(1)

125. How to copy a list?

newlist = oldlist.copy()

126. How to flatten a nested list?

[item for sublist in nested for item in sublist]

127. How to use enumerate?

for i, val in enumerate(mylist):

128. What does any() do?

  • Returns True if at least one element is truthy.

129. What does all() do?

  • Returns True if all elements are truthy.

130. How to check if a list is empty?

if not mylist:

131. Difference between list() and []?

  • list() can convert iterables; [] creates a literal list.

132. How to remove duplicates but keep order?

list(dict.fromkeys(mylist))

133. What is the difference between sort() and sorted()?

  • sort() modifies list in-place
  • sorted() returns a new list

134. How to zip two lists?

list(zip(list1, list2))

135. How to unpack a list?

a, b, *rest = mylist

136. What does reversed() do?

  • Returns an iterator to reverse the sequence.

137. What is the use of map()?

  • Applies a function to all items:
map(str, [1, 2])

138. What does filter() do?

  • Filters elements based on a function.

139. What does reduce() do?

  • Applies function cumulatively to the list (from functools).

140. How to use list comprehension with condition?

[x for x in list if x % 2 == 0]

141. How to create a tuple?

t = (1, 2)

142. What’s tuple unpacking?

a, b = (1, 2)

143. Are tuples hashable?

  • Yes, if they contain only immutable elements.

144. How to convert list to tuple?

tuple(mylist)

145. What is a frozenset?

  • Immutable set.

146. What are set operations?

union(), intersection(), difference(), symmetric_difference()

147. How to check subset/superset?

set1.issubset(set2), set1.issuperset(set2)

148. What is a dictionary comprehension?

{k: k**2 for k in range(5)}

149. How to merge two dictionaries?

{**dict1, **dict2}

150. How to get keys/values/items from dict?

d.keys(), d.values(), d.items()

151. What is the use of get() in dict?

d.get("key", "default")

152. How to check if key exists in dict?

if "key" in d:

153. What is the difference between pop() and del?

  • pop(): returns and removes
  • del: only removes

154. How to loop through a dict?

for k, v in d.items():

155. What is defaultdict?

  • Dict with default values from collections.

156. What is Counter?

  • Counts occurrences in a collection.

157. How to sort a dict by values?

sorted(d.items(), key=lambda x: x[1])

158. What is OrderedDict?

  • Dict that remembers insertion order (Python 3.7+ dict also does).

159. What does dict.setdefault() do?

  • Returns key if exists, else inserts it with default.

160. How to invert a dictionary?

{v: k for k, v in d.items()}

161. What is map()?

  • Applies a function to each item.

162. What is filter()?

  • Filters items that return True for the function.

163. What is reduce() used for?

  • Applies function cumulatively, e.g., sum, product.

164. What are higher-order functions?

  • Functions that take or return functions.

165. What are closures?

  • A nested function that remembers values from enclosing scope.

166. What is a lambda function?

  • Anonymous, inline function:
lambda x: x + 1

167. What is a partial function?

  • Function with some arguments fixed using functools.partial.

168. What are decorators used for?

  • Wrap and modify functions.

169. Can decorators take arguments?

  • Yes, via another wrapping function.

170. What is the use of functools.wraps?

  • Preserves metadata of the original function.

171. What is currying?

  • Converting a function of multiple arguments to one with single arguments.

172. How to memoize functions?

  • Using functools.lru_cache.

173. How to define a custom decorator?

def decorator(fn):
 def wrapper(*args, **kwargs):
  return fn(*args, **kwargs)
  return wrapper

174. Can a function return another function?

  • Yes. Functions are first-class citizens.

175. What is recursion limit in Python?

  • Default is 1000, changeable with sys.setrecursionlimit().

176. What is tail recursion?

  • A recursion where recursive call is the last operation.

177. Does Python support tail call optimization?

  • No, to keep stack traces.

178. What are pure functions?

  • Functions without side effects.

179. What are impure functions?

  • Functions with side effects (e.g., I/O).

180. What is the difference between yield and return?

  • yield: pauses function
  • return: ends function

181. What is an iterator?

  • An object with __iter__() and __next__().

182.How to make a class iterable?

  • Define __iter__() and __next__().

183. How to get an iterator from a list?

iter(mylist)

184. What is StopIteration?

  • Signals the end of iteration.

185. What is a generator function?

  • A function that uses yield to return values one at a time.

186. How to create a generator expression?

(x*x for x in range(10))

187. What is the difference between generator and list comprehension?

  • Generator: lazy, memory-efficient
  • List comprehension: eager, uses memory

188. What is next() used for?

  • Fetches the next value from iterator.

189. How to use send() in a generator?

  • Sends a value into generator after yielding.

190. What is itertools?

  • A module with efficient looping utilities.

191. Name some itertools functions.

  • count(), cycle(), repeat(), product(), combinations()

192. What is the difference between range() and xrange()?

  • xrange() exists in Python 2 only. range() in Python 3 is a generator-like object.

193. What is lazy evaluation?

  • Delaying computation until needed (e.g., generators).

194. What is a coroutine?

  • A generator that can accept values with send().

195. What is async/await in Python?

  • Used for asynchronous programming.

196. What is asyncio?

  • A library for writing async code.

197. Can generators be recursive?

  • Yes, but use yield from.

198. What does yield from do?

  • Delegates to another generator.

199. What happens if you call next() on a generator that’s done?

  • Raises StopIteration.

200. How to check if an object is iterable?

from collections.abc import Iterable isinstance(obj, Iterable)

201. What is unit testing?

  • Testing individual parts (units) of code.

202. What module is used for unit testing?

  • unittest

203. How do you write a test case?

import unittest
class TestMath(unittest.TestCase):
 def test_add(self):
   self.assertEqual(1 + 1, 2)

204. What is an assertion?

  • A check if a condition is true in a test.

205. Common unittest methods?

  • assertEqual(a, b)
  • assertTrue(x)
  • assertRaises(Error)

206. What is mocking in testing?

  • Replacing parts of system with mock objects.

207. How to use pytest?

  • Install with pip install pytest, run tests with pytest.

208. How to skip a test?

  • Use @unittest.skip("reason").

209. How to group tests?

  • Use test classes or test suites.

210. What’s the difference between assert and assertEqual?

  • assert is Python built-in; assertEqual is part of unittest.

211. What is TDD (Test Driven Development)?

  • Writing tests before the code implementation.

212. How do you test exceptions in unittest?

  • Using assertRaises.

213. What is nose or tox?

  • Test runners and automation tools for Python.

214. How to test code coverage?

  • Use coverage.py.

215. How to debug in Python?

  • Use pdb, breakpoints, or IDE tools.

216. What is a breakpoint?

  • A pause point in code execution for debugging.

217. How to start a debug session?

  • Insert breakpoint() or use pdb.set_trace().

218. How to step through code?

  • In pdb: n: next s: step into c: continue

219. How to print stack trace?

  • Use traceback.print_exc().

220. What is assertLogs() in unittest?

  • Tests log output.

221. How to connect to a database in Python?

  • Using libraries like sqlite3, psycopg2, SQLAlchemy.

222. How to connect to SQLite?

import sqlite3  
conn = sqlite3.connect('test.db')

223. How to create a table in SQLite?

cursor.execute("CREATE TABLE IF NOT EXISTS users (id INT, name TEXT)")

224. How to insert data into SQLite?

cursor.execute("INSERT INTO users VALUES (?, ?)", (1, "Alice"))

225. How to read data from a table?

cursor.execute("SELECT * FROM users")
rows = cursor.fetchall()

226. What is parameterized query?

  • SQL query using placeholders to prevent SQL injection.

227. What is ORM?

  • Object-Relational Mapper (e.g., SQLAlchemy, Django ORM).

228. How to define a model in SQLAlchemy?

class User(Base):
    `__tablename`__ = 'users'
    id = Column(Integer, primary_key=True)
    name = Column(String)

229. How to create a session in SQLAlchemy?

Session = sessionmaker(bind=engine)
session = Session()

230. How to filter data in SQLAlchemy?

session.query(User).filter(User.name == "Alice")

231. How to update data in SQLAlchemy?

user.name = "Bob"
session.commit()

232. How to delete a record in SQLAlchemy?

session.delete(user)

233. What is a transaction?

  • Group of operations treated as a single unit.

234. How to use transactions in Python?

  • Automatically with context managers or manually with commit() and rollback().

235. How to close a database connection?

conn.close()

236. How to use pandas with SQL?

df = pd.read_sql("SELECT * FROM users", conn)

237. How to write a pandas DataFrame to SQL?

df.to_sql("users", conn)

238. What is SQL injection?

  • Malicious SQL code via user input; avoid by using parameterized queries.

239. How to handle NULL in Python with SQL?

  • Use None in Python; maps to NULL in SQL.

240. What’s the difference between fetchone() and fetchall()?

  • fetchone(): one record
  • fetchall(): all records

241. What is Flask?

  • A lightweight WSGI web framework.

242. What is Django?

  • A full-featured web framework for building complex sites.

243. How to install Flask?

pip install flask

244. Basic Flask example?

from flask import Flask  
app = Flask(`__name`__)  
@app.route('/')  
def home():  
  return "Hello World"

245. What is @app.route()?

  • Defines URL routes.

246. How to pass parameters in URL (Flask)?

@app.route('/user/<name>')

247. How to handle forms in Flask?

  • Use request.form, request.args

248. How to render templates in Flask?

render_template('index.html')

249. How to return JSON in Flask?

from flask import jsonify  
return jsonify(data)

250. What is flask run?

  • Command to run Flask development server.

251. How to set environment variables in Flask?

export FLASK_APP=app.py  
export FLASK_ENV=development

252. What is the Django ORM?

  • Object-relational mapper to interact with databases.

253. What is a Django model?

  • Class that maps to a database table.

254. What is a Django view?

  • A function/class that handles a request and returns a response.

255. How to render HTML in Django?

  • Use render(request, 'template.html')

256. What is manage.py?

  • Command-line tool to interact with Django project.

257. What is migrate in Django?

  • Apply changes in models to the database schema.

258. What is urls.py used for?

  • Maps URLs to views.

259. What is Django’s settings.py?

  • Holds project configuration.

260. How to create a Django project?

django-admin startproject mysite

261. How to make HTTP requests in Python?

  • Use the requests library.

262. Basic GET request with requests?

import requests  
r = requests.get("https://example.com")

263. How to send data with POST?

requests.post(url, data={'key': 'value'})

264. How to send JSON in request?

requests.post(url, json=data)

265. How to get response headers?

r.headers

266. How to get JSON response?

r.json()

267. What is an API?

  • Application Programming Interface.

268. What is a REST API?

  • A web API that follows REST principles.

269. How to handle timeouts in requests?

requests.get(url, timeout=5)

270. What is status_code in requests?

  • HTTP response status (e.g., 200, 404)

271. How to handle cookies in requests?

r.cookies

272. How to download a file from URL?

r = requests.get(url)  
open("file", "wb").write(r.content)

273. What is socket module used for?

  • Low-level network communication.

274. How to create a socket server?

socket.socket().bind(('localhost', 1234))

275. How to send data via socket?

  • Use send() and recv() methods.

276. What is JSON?

  • JavaScript Object Notation, used for data exchange.

277. How to parse JSON in Python?

import json  
json.loads(json_str)

278. How to convert dict to JSON?

json.dumps(my_dict)

279. What is WebSocket?

  • Full-duplex communication channel over a single TCP connection.

280. How to create REST API in Flask?

  • Use Flask + Flask-RESTful.

281. How to get current time in Python?

import datetime  
datetime.datetime.now()

282. How to measure time taken by code?

import time  
start = time.time()  
# code  
print(time.time() - start)

283. How to run system commands in Python?

import os  
os.system("ls")

284. How to read environment variables?

os.environ.get("HOME")

285. How to use subprocess?

subprocess.run(["ls", "-l"])

286. How to list files in directory?

os.listdir()

287. How to check if a file exists?

os.path.exists("file.txt")

288. What is shutil used for?

  • File and directory operations.

289. How to copy a file in Python?

shutil.copy("src", "dst")

290. How to delete a file?

os.remove("file.txt")

291. What is the use of glob module?

  • Pattern matching for filenames.

292. How to create a zip file?

import zipfile  
with zipfile.ZipFile("test.zip", "w") as zipf:
 zipf.write("file.txt")

293. How to read a config file?

  • Use configparser module.

294. How to serialize data in Python?

  • Use pickle, json.

295. What is pickle used for?

  • Serialize/deserialize Python objects.

296. How to get memory usage of object?

import sys  
sys.getsizeof(obj)

297. How to handle CLI arguments?

  • Use argparse.

298. How to write a CLI program in Python?

  • Use argparse or click.

299. How to profile Python code?

  • Use cProfile.

300. How to schedule tasks in Python?

  • Use schedule, APScheduler, or cron.

On this page

1. What is Python?2. What are Python’s key features?3. What are Python’s data types?4. What is a dynamically typed language?5. What is PEP 8?6. What is the difference between is and ==?7. How is memory managed in Python?8. What is the difference between a list and a tuple?9. What is a dictionary in Python?10. How do you comment in Python?11. What are Python control structures?12. How to define a function in Python?13.W hat is a lambda function?14. What are *args and kwargs?15. What is recursion?16. What is the purpose of return?17. What is pass?18. What is the use of yield?19. What’s the difference between global and nonlocal?20. What is a docstring?21. What is OOP?22. What is a class?23. What is an object?24. What are __init__ and self?25. What is inheritance?26. What is multiple inheritance?27. What is encapsulation?28. What is polymorphism?29. What are magic methods?30. What is a class method and static method?31. How to open a file in Python?32. How to read/write a file?33.. What is with open()?34. What is a module?35. What is a package?36. How to import a module?37. How to list installed modules?38. What is the difference between import and from?39. How to install packages?40. How to create a virtual environment?41. What is an exception?42. How to handle exceptions?43. What is finally used for?44. What is the use of raise?45. Name some common exceptions.46. What is assert?47. How to debug in Python?48. What is traceback?49. How to log errors?50. What is the difference between error and exception?51. What is a generator?52. What is a decorator?53. What are comprehensions?54. What is a context manager?55. What is a metaclass?56. What is duck typing?57. What is monkey patching?58. What is GIL (Global Interpreter Lock)?59. What is multithreading?60. What is multiprocessing?61. What is a list?62. What is a tuple?63. What is a set?64. What is a dictionary?65. How to merge two lists?66. How to sort a list?67. What is a shallow copy vs deep copy?68. How to reverse a list?69. How to remove duplicates?70. How to iterate over a dictionary?71. What is NumPy used for?72. What is pandas?73. What is matplotlib?74. What is Flask?75. What is Django?76. What is SQLAlchemy?77. What is pip?78. What is Jupyter Notebook?79. What is virtualenv?80. What is pytest?81. What is slicing?82. How to check Python version?83. What is __name__ == "__main__" used for?84. What is list comprehension?85. What is the walrus operator :=?86. What are f-strings?87. How to convert string to int?88. How to convert int to string?89. What is a ternary operator?90. What is dir()?91. Swap two variables.92. Check if string is palindrome.93. Factorial using recursion.94. Fibonacci series.95. Check for prime.96. Reverse a string.97. Sum of list.98. Find max in list.99. List even numbers from list.101. How do you create a string in Python?102. How do you concatenate strings?103. How to repeat a string 3 times?104. How to find the length of a string?105. How to convert to uppercase/lowercase?106. How to check if a string starts/ends with a substring?107. How to find a substring in a string?108. How to replace part of a string?109. How to split a string?110. How to join a list into a string?111. How to strip whitespace from a string?112. How to check if string is digit?113. How to reverse a string?114. What is a raw string?115. How to format a string with variables?116. ### What does zfill() do?117. How to count substrings?118. What is isalnum()?119. How to center a string?120. What’s the difference between isalpha() and isdigit()?121. How to add item to a list?122. How to insert item at specific index?123. How to remove an item by value?124. How to remove an item by index?125. How to copy a list?126. How to flatten a nested list?127. How to use enumerate?128. What does any() do?129. What does all() do?130. How to check if a list is empty?131. Difference between list() and []?132. How to remove duplicates but keep order?133. What is the difference between sort() and sorted()?134. How to zip two lists?135. How to unpack a list?136. What does reversed() do?137. What is the use of map()?138. What does filter() do?139. What does reduce() do?140. How to use list comprehension with condition?141. How to create a tuple?142. What’s tuple unpacking?143. Are tuples hashable?144. How to convert list to tuple?145. What is a frozenset?146. What are set operations?147. How to check subset/superset?148. What is a dictionary comprehension?149. How to merge two dictionaries?150. How to get keys/values/items from dict?151. What is the use of get() in dict?152. How to check if key exists in dict?153. What is the difference between pop() and del?154. How to loop through a dict?155. What is defaultdict?156. What is Counter?157. How to sort a dict by values?158. What is OrderedDict?159. What does dict.setdefault() do?160. How to invert a dictionary?161. What is map()?162. What is filter()?163. What is reduce() used for?164. What are higher-order functions?165. What are closures?166. What is a lambda function?167. What is a partial function?168. What are decorators used for?169. Can decorators take arguments?170. What is the use of functools.wraps?171. What is currying?172. How to memoize functions?173. How to define a custom decorator?174. Can a function return another function?175. What is recursion limit in Python?176. What is tail recursion?177. Does Python support tail call optimization?178. What are pure functions?179. What are impure functions?180. What is the difference between yield and return?181. What is an iterator?182.How to make a class iterable?183. How to get an iterator from a list?184. What is StopIteration?185. What is a generator function?186. How to create a generator expression?187. What is the difference between generator and list comprehension?188. What is next() used for?189. How to use send() in a generator?190. What is itertools?191. Name some itertools functions.192. What is the difference between range() and xrange()?193. What is lazy evaluation?194. What is a coroutine?195. What is async/await in Python?196. What is asyncio?197. Can generators be recursive?198. What does yield from do?199. What happens if you call next() on a generator that’s done?200. How to check if an object is iterable?201. What is unit testing?202. What module is used for unit testing?203. How do you write a test case?204. What is an assertion?205. Common unittest methods?206. What is mocking in testing?207. How to use pytest?208. How to skip a test?209. How to group tests?210. What’s the difference between assert and assertEqual?211. What is TDD (Test Driven Development)?212. How do you test exceptions in unittest?213. What is nose or tox?214. How to test code coverage?215. How to debug in Python?216. What is a breakpoint?217. How to start a debug session?218. How to step through code?219. How to print stack trace?220. What is assertLogs() in unittest?221. How to connect to a database in Python?222. How to connect to SQLite?223. How to create a table in SQLite?224. How to insert data into SQLite?225. How to read data from a table?226. What is parameterized query?227. What is ORM?228. How to define a model in SQLAlchemy?229. How to create a session in SQLAlchemy?230. How to filter data in SQLAlchemy?231. How to update data in SQLAlchemy?232. How to delete a record in SQLAlchemy?233. What is a transaction?234. How to use transactions in Python?235. How to close a database connection?236. How to use pandas with SQL?237. How to write a pandas DataFrame to SQL?238. What is SQL injection?239. How to handle NULL in Python with SQL?240. What’s the difference between fetchone() and fetchall()?241. What is Flask?242. What is Django?243. How to install Flask?244. Basic Flask example?245. What is @app.route()?246. How to pass parameters in URL (Flask)?247. How to handle forms in Flask?248. How to render templates in Flask?249. How to return JSON in Flask?250. What is flask run?251. How to set environment variables in Flask?252. What is the Django ORM?253. What is a Django model?254. What is a Django view?255. How to render HTML in Django?256. What is manage.py?257. What is migrate in Django?258. What is urls.py used for?259. What is Django’s settings.py?260. How to create a Django project?261. How to make HTTP requests in Python?262. Basic GET request with requests?263. How to send data with POST?264. How to send JSON in request?265. How to get response headers?266. How to get JSON response?267. What is an API?268. What is a REST API?269. How to handle timeouts in requests?270. What is status_code in requests?271. How to handle cookies in requests?272. How to download a file from URL?273. What is socket module used for?274. How to create a socket server?275. How to send data via socket?276. What is JSON?277. How to parse JSON in Python?278. How to convert dict to JSON?279. What is WebSocket?280. How to create REST API in Flask?281. How to get current time in Python?282. How to measure time taken by code?283. How to run system commands in Python?284. How to read environment variables?285. How to use subprocess?286. How to list files in directory?287. How to check if a file exists?288. What is shutil used for?289. How to copy a file in Python?290. How to delete a file?291. What is the use of glob module?292. How to create a zip file?293. How to read a config file?294. How to serialize data in Python?295. What is pickle used for?296. How to get memory usage of object?297. How to handle CLI arguments?298. How to write a CLI program in Python?299. How to profile Python code?300. How to schedule tasks in Python?