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) |
Drop Dead Simple Interview Questions - nilamo - Feb-13-2017 What's some good interview questions? There's FizzBuzz, and "print a ladder", what else do you have? And sure, let's share answers why not. Since I mentioned two, I'll go through them. FizzBuzz: In a given range (let's say 15), print something to the screen. If the number is divisible by 3, print "Fizz". If it's divisible by 5, print "Buzz". If it's divisible by both, "FizzBuzz". If it's not divisible by either, print the number itself. >>> for ans in map(lambda n: "FizzBuzz" if 0==n%3 and 0==n%5 else "Fizz" if 0==n%3 else "Buzz" if 0==n%5 else n, range(1, 16)): ... print(ans) ... 1 2 Fizz 4 Buzz Fizz 7 8 Fizz Buzz 11 Fizz 13 14 FizzBuzzIf 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) ... 1 2 Fizz 4 Buzz Fizz 7 8 Fizz Buzz 11 Fizz 13 14 FizzBuzzPrint a Ladder: Given a range (again, let's say 15), print a given text that many times, to give the appearance of steps. >>> def ladder(): ... text = input("What you wanna see? ") ... return [text*n for n in range(int(input("How many steps? ")))] ... >>> for step in ladder(): ... print(step) ... What you wanna see? Spam How many steps? 15 Spam SpamSpam SpamSpamSpam SpamSpamSpamSpam SpamSpamSpamSpamSpam SpamSpamSpamSpamSpamSpam SpamSpamSpamSpamSpamSpamSpam SpamSpamSpamSpamSpamSpamSpamSpam SpamSpamSpamSpamSpamSpamSpamSpamSpam SpamSpamSpamSpamSpamSpamSpamSpamSpamSpam SpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpam SpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpam SpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpam SpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamSpamRight. So the questions should be super easy, and exist for no reason other than to prove the person knows more than just the requisite technology stack lingo to fake it. RE: Drop Dead Simple Interview Questions - metulburr - Feb-13-2017 Quote:What's some good interview questions?I like the idea of a thread showing possible or realistic questions asked....but i dont think the thread should be gen coding help. Maybe discussions? Or stickied in jobs? OR maybe tutorials....im not really sure where to put it. RE: Drop Dead Simple Interview Questions - snippsat - Feb-13-2017 Moved it Quote:If you actually want the job, then this would be better (or having four print statements, and using "end=''" a lot):Njaa i could be that interviewer now a little functional programmering,and are happy with map and lambda. The next question could then be,has it side effects RE: Drop Dead Simple Interview Questions - nilamo - Feb-13-2017 Yeah, I had no idea, so I went general. I was thinking Jobs also, but the description is very specifically for job posters or seekers, not general info about jobs. RE: Drop Dead Simple Interview Questions - metulburr - Feb-13-2017 Quote:I was thinking Jobs also, but the description is very specifically for job posters or seekers, not general info about jobs.i personally think it would depend on how many people participate with different ideas, as to where it should go at the end. IF not a lot of people add things, i think it should stay here in discussions. RE: Drop Dead Simple Interview Questions - nilamo - Feb-13-2017 Simple file reading? I'm not sure if this is better than csv, or if just seeing the general way people handle resources is more important... >>> text = ''' ... hello, my name is ... wait, who am i? ... ''' >>> text = text.split('\n') >>> with open('saved_data.txt', 'w') as f: ... for line in text: ... print(line, file=f) ... >>> text = "spam" >>> # now we don't have any reference to the original text floating around ... >>> with open('saved_data.txt') as f: ... for line in f: ... print(line.rstrip()) ... hello, my name is wait, who am i? >>> RE: Drop Dead Simple Interview Questions - ichabod801 - Feb-13-2017 I never ask job applicants to write a program for me. I ask them to send me a program they've already written. That usually tells me plenty. Unfortunately, it's rarely anything I want to hear. RE: Drop Dead Simple Interview Questions - Larz60+ - Feb-13-2017 It may also be his friends code RE: Drop Dead Simple Interview Questions - nilamo - Feb-13-2017 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. RE: Drop Dead Simple Interview Questions - micseydel - Feb-13-2017 I wouldn't ever give Fizzbuzz, I'd be afraid of insulting the candidate. Are you interviewing them for a specific role or position? Are they expected to be familiar with computer science? A warmup question I often give is "write a function which takes in a string and returns true if the string represents a number." The candidate is meant to clarify the requirements, and be able to code it up after. If they write something that just handles non-negative integers, I start providing additional sample cases for negative and floating point numbers. They also often don't accommodate for "-", "." and sometimes even after that, "-.". |