r/PythonLearning 5h ago

What's your favorite Python interview question?

Not a trick question or LeetCode puzzle. What's a question that actually reveals whether someone understands Python?

1 Upvotes

7 comments sorted by

4

u/fisadev 5h ago

In some past interview format that I'm no longer doing, I used to ask candidates to explain in simple terms how async code runs, and what's the difference between async, multithreading and multiprocessing.

Very few people were able to answer that in a meaningful way.

Technically, knowing that doesn't mean you know python as a whole, you could very well focus on learning just that and ignore plenty of other important things. But in practice there was a very strong correlation between understanding that and having a deep understanding of python in general (exposed by the rest of the questions I was asking too).

Another good one is to explain how function arguments are passed, if they are passed by value, by reference, or something else. So many wrong answers talking about different modes depending on the mutability/immutability of the values, when in reality everything is passed as a new reference to the same object (no special cases, no different modes, it's always just that).

2

u/3rrr6 4h ago

What do you hate most about Python?

This goes for any technology, if you don't hate some aspects of the technology then you haven't really used it.

It also clues you in on the depth, if their gripes are common things, then they aren't an expert, if their gripes involve things you've never even heard of, then you know they've been deep in the Python woods that only the professionals would dare explore.

2

u/sububi71 4h ago

"Any other references than 'Mother'?"

1

u/silvertank00 4h ago

A. How would you create a word counter without dicts.
There is no good answer, but shows a lot about how someone thinks. Some examples to solve this:

  • nested lists
  • simple dataclass objects
  • reimplement dicts but not call them that

B. What is the most cursed but still working and somewhat reasonable thing that you did in python (or any other languages). Bonus point if it can be demonstrated. Example: exec'd python code in string format can run faster than the same code but put in the python file that runs the exec.

2

u/Excellent-Practice 1h ago

Is the challenge to keep track of each unique word in a text and count how many times each one appears?

My first thought was to juggle indexes between a list of strings and a list of ints, but I guess you could also build a class that adds an attribute every time it encounters a new word. Like you said, essentially reinventing dictionaries

1

u/SpamNot 13m ago

This is basically like asking how fast you'd run a 5K after amputated your leg.