TGViewer
Data Analytics Data Analytics @sqlspecialist · 111K subscribers
Post #2237 5.54K
Python Interview Questions with Answers Part-3: ☑️

21. How do you perform basic statistical operations in Python? 
    Use libraries like NumPy (np.mean(), np.median(), np.std()) and Pandas (df.describe()) for statistics like mean, median, variance, etc.

22. What libraries do you use for data visualization? 
    Common ones are Matplotlib, Seaborn, Plotly, and sometimes Bokeh for interactive plots.

23. How do you create plots using Matplotlib or Seaborn? 
    In Matplotlib:
import matplotlib.pyplot as plt
plt.plot(x, y)
plt.show()

In Seaborn:
import seaborn as sns
sns.barplot(x='col1', y='col2', data=df)


24. What is the difference between .apply() and .map() in Pandas?
⦁ .apply() can work on entire Series or DataFrames and accepts functions.
⦁ .map() maps values in a Series based on a dict, Series, or function.

25. How do you export Pandas DataFrames to CSV or Excel files? 
    Use df.to_csv('file.csv') or df.to_excel('file.xlsx').

26. What is the difference between Python’s range() and xrange()? 
    In Python 2, range() returns a list, xrange() returns an iterator for better memory usage. In Python 3, range() behaves like xrange().

27. How can you profile and optimize Python code? 
    Use modules like cProfile, timeit, or line profilers to find bottlenecks, then optimize with better algorithms or vectorization.

28. What are Python decorators and give a simple example? 
    Functions that modify other functions without changing their code. 
    Example:
def decorator(func):
    def wrapper():
        print("Before")
        func()
        print("After")
    return wrapper

@decorator
def say_hello():
    print("Hello")


29. How do you handle dates and times in Python? 
    Use datetime module and libraries like pandas.to_datetime() or dateutil to parse, manipulate, and format dates.

30. Explain list slicing in Python. 
    Get sublists using syntax list[start:stop:step]. Example: lst[1:5:2] picks items from index 1 to 4 skipping every other.

React ♥️ for Part 4
  • ❤ 17
  • 👏 1
More from @sqlspecialist
  1. Oct 17, 2026𝗜𝗕𝗠 𝗙𝗥𝗘𝗘 𝗧𝗘𝗖𝗛 𝗖𝗢𝗨𝗥𝗦𝗘𝗦 𝟮𝟬𝟮𝟲! 🎓 Explore IBM Cognitive Class and build…
  2. Oct 16, 2026𝗗𝗮𝘁𝗮 𝘀𝗰𝗶𝗲𝗻𝗰𝗲 𝗖𝗲𝗿𝘁𝗶𝗳𝗶𝗰𝗮𝘁𝗶𝗼𝗻 𝗪𝗶𝘁𝗵 𝗔𝗜😍 Future Ready Data Scien…
  3. Oct 14, 2026I could then categorize customers into groups such as Active, At Risk, and Inactive and su…
  4. Oct 14, 2026📊 Data Analyst Interview Series — Part 10 Guys, let's continue our Data Analyst Interview…
  5. Oct 13, 2026📊 Data Analyst Interview Series — Part 9 Guys, let's continue our Data Analyst Interview…
  6. Oct 13, 2026𝗧𝗢𝗣 𝗙𝗥𝗘𝗘 𝗖𝗢𝗨𝗥𝗦𝗘𝗦 𝗧𝗢 𝗕𝗢𝗢𝗦𝗧 𝗬𝗢𝗨𝗥 𝗦𝗞𝗜𝗟𝗟𝗦 𝗜𝗡 𝟮𝟬𝟮𝟲! Explor…
Threads Profile ViewerView any public Threads profile without an account.Open ThreadLook →Writing with AI? Make it sound human.Metric37 rewrites AI drafts so they read naturally. Free AI detector, 1,500 words free.Try Metric37 →