Python Forum
Drop Dead Simple Interview Questions - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: General (https://python-forum.io/forum-1.html)
+--- Forum: News and Discussions (https://python-forum.io/forum-31.html)
+--- Thread: Drop Dead Simple Interview Questions (/thread-2042.html)

Pages: 1 2 3


RE: Drop Dead Simple Interview Questions - Larz60+ - Feb-13-2017

The best job I ever had, i sat down in a room of six people and was grilled by extremely knowledgeable people
I was called back and grilled by two of their superiors.
When it was all over and I got the job, I thanked them for letting me know in advance who I would be working
for and with.
That job was at Instrumentation Laboratories.
I worked initially on new product development., and specifically
on a new concept scanning plasma monochrometer.
After the first year, I was called in for my first review, asked how I thought I did
(and was expected to give a through, and truthful answer).
I was thanked and given a healthy raise.

Pure bliss.

Unfortunately, several years later we were purchased by Allied Chemical who quickly (within a year)
sold off any division taking in less that 30 million. Of which, we were one.


RE: Drop Dead Simple Interview Questions - ichabod801 - Feb-13-2017

(Feb-13-2017, 08:41 PM)nilamo Wrote: I feel like writing code, right in front of someone, it a good idea. Even if it's not a real language, and just pseudocode. Gluing together snippets from google can only get you so far.

If they're gluing together snippets from Google it's pretty obvious in the code sample they provide. I find you can ask questions in English to get deeper. Describe how you've used such and such technique in a program. How would you approach this or that problem?


RE: Drop Dead Simple Interview Questions - volcano63 - Apr-17-2017

(Feb-13-2017, 05:56 PM)nilamo Wrote: If you actually want the job, then this would be better (or having four print statements, and using "end=''" a lot):
>>> for n in range(1, 16):
...     ans = ""
...     if 0 == n%3:
...         ans += "Fizz"
...     if 0 == n%5:
...         ans += "Buzz"
...     if not ans:
...         ans = n
...     print(ans)
.............
Actually, IMHO this is not the best answer:
  • You don't need incremental assignment under the first if
  • The last if would better be elif



RE: Drop Dead Simple Interview Questions - nilamo - Apr-17-2017

(Apr-17-2017, 07:50 PM)volcano63 Wrote:
  • The last if would better be elif

I disagree. That would give extra semantic meaning to the "divisible by 5" check that doesn't exist for the "divisible by 3" check. And extra semantic meaning serves no purpose other than to confuse whoever looks at the code in the future.

If you were to look at the code, without knowing the problem ahead of time, you'd see two options:
a) divisible by 3 and
b) divisible by 5

...except that there's an extra clause tacked on to option b that sort of reads "if it's not divisible by 5, and also if nothing else happened so far, then just use the number". Which makes you stop and wonder why option b is special compared to option a. It wouldn't be immediately obvious that it isn't obvious, it just happens to come last in the loop.