Python Coding Interviews: Tips & Best Practices

James Uejio

James Uejio 22 Lessons 2h 21m

You’ve made it past the phone call with the recruiter, and now it’s time to show that you know how to solve problems with actual code. Whether it’s a HackerRank exercise, a take-home assignment, or an onsite whiteboard interview, this is your moment to prove your coding interview skills.

But interviews aren’t just about solving problems: they’re also about showing that you can write clean production code. This means that you have a deep knowledge of Python’s built-in functionality and libraries. This knowledge shows companies that you can move quickly and won’t duplicate functionality that comes with the language just because you don’t know it exists.

At Real Python, we’ve put our heads together and discussed what tools we’re always impressed to see in coding interviews. This course will walk you through the best of that functionality, starting with Python built-ins, then Python’s native support for data structures, and finally Python’s powerful (and often underappreciated) standard library.

In this course, you’ll learn how to:

  • Use enumerate() to iterate over both indices and values
  • Debug problematic code with breakpoint()
  • Format strings effectively with f-strings
  • Sort lists with custom arguments
  • Use generators instead of list comprehensions to conserve memory
  • Define default values when looking up dictionary keys
  • Count hashable objects with the collections.Counter class
  • Use the standard library to get lists of permutations and combinations

Part 2: Leveraging Core Data Structures

6 Lessons 31m

1. Sets 06:40

Part 3: Using Python's Standard Library

4 Lessons 22m

About James Uejio

James Uejio James Uejio

James is an avid Pythonista and creates video tutorials for Real Python. He is a web developer at Wish and also produces lo-fi hip hop and plays jazz guitar.

» More about James

Each tutorial at Real Python is created by a team of developers so that it meets our high quality standards. The team members who worked on this tutorial are:

Participant Comments

Ricardo J Lima on May 16, 2020

Yes, I reached the end of the course and it was extremely valuable! Thanks a lot for your work.

Cristian Palau on May 4, 2020

Thanks for the useful tips!

Pygator on April 30, 2020

Lots of nice features displayed, and a review of some basic to intermediate skills. Thanks; the problems were interesting.

Hey James, thanks for this outstanding series, it’s actually way more than a help for an interview - it’s an overview of a lot of cool tips and tricks.

However, in this example I think that running the doctest with these expected outputs doesn’t quite cut it, especially for add_person and bypass_queue. If I understand that correctly, the return string of those methods is only based on the input name, not on what happens to the list/deque. Maybe checking for the actual state of the deque could provide a better solution? But maybe I’m just a bit nitpicky here…

Whatever, the series is great, learned a lot of things I can expand on now.

Best, Max

Qasim Albaqali on April 22, 2020

This is such a good course! The content is superb, thank you :)

« Browse All Courses