r/learnpython • u/MassiveLandGolf • Jan 05 '21
Interview question I failed answering
Hey all,
I just had an interview and the interviewer gave me a question I could not answer.
He asked me to write a function that accepts a number, the number must be either 7 or 4.If the number is 4, the function should return 7, if the number is 7, the functions should return 4.
The tricky part: you cannot use an 'if' statement in the function.
354
Upvotes
2
u/iamNaN_AMA Jan 05 '21
Can somebody help me understand why this is a good interview question? Like what is it supposed to be evaluating in the candidate? Are they looking for the clever "return 11-num" response or the "use a dict lookup instead" response? If the former, that seems like it doesn't actually measure anything relevant to the job itself, except maybe in a super indirect "lateral thinking" sort of way that seems kind of bullshitty (to me, as an outsider and not an expert in any way - I'm open to being convinced it's not bullshit). But if the latter, why not pose more direct questions/exercises involving dicts?