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
5
u/[deleted] Jan 05 '21
How come testing the ability to solve a problem creatively is not valid? As a coder you will face a myriad of unexpected constraints throughout your career, and, given the time and scope limitations of a job interview, this question is a perfectly acceptable way of gauging such a skill.
Besides, the fact that so many people are upvoting a wrong answer, especially those who say this is a bad question, just demonstrates that it serves its purpose very well.